Job Help

jackson1306
Member Posts: 5
Hi can anyone help in essense I need to join two tables based on a key field.
Once I have done this I then need to say if field A in table A = value && Field B in Table B = value then delete record but my job doesn't compile. Please could someone point me in the right direction ?.
Kind Regards
Andrew
static void DataCleanse(Args _args)
{
OCSSalesOrderHold OCSSalesOrderHold;
SalesTable SalesTable;
;
while select SalesTable
join OCSSalesOrderHold
where OCSSalesOrderHold.SalesId==SalesTable.SalesId
delete_from OCSSalesOrderHold
where SalesTable.DocumentStatus == SalesTable.DocumentStatus ::Invoice
&& OCSSalesOrderHold.Status ==OCSSalesOrderHold.Status ::Held
}
Once I have done this I then need to say if field A in table A = value && Field B in Table B = value then delete record but my job doesn't compile. Please could someone point me in the right direction ?.
Kind Regards
Andrew
static void DataCleanse(Args _args)
{
OCSSalesOrderHold OCSSalesOrderHold;
SalesTable SalesTable;
;
while select SalesTable
join OCSSalesOrderHold
where OCSSalesOrderHold.SalesId==SalesTable.SalesId
delete_from OCSSalesOrderHold
where SalesTable.DocumentStatus == SalesTable.DocumentStatus ::Invoice
&& OCSSalesOrderHold.Status ==OCSSalesOrderHold.Status ::Held
}
0
Comments
-
Remove the while select statement and use join in the delete_from statement.
like this
ttsbegin;
delete_from OCSSalesOrderHold
join sales Table
where salesTable.SaLesId == OCSSalesOrderHold.SalesId
&& SalesTable.DocumentStatus == DocumentStatus::Invoice
&& OCSSalesOrderHold.Status == Status ::Held;///Use the enumType here(EnumName::Element)
ttscommit;Kranthi0 -
When I run this query I get error 134 inner or outer join is illegal in this context.
Any ideas please ?.
Regards
A
Query So Far:
static void DataCleanse(Args _args)
{
OCSSalesOrderHold OCSSalesOrderHold;
SalesTable SalesTable;
;
ttsbegin;
delete_from OCSSalesOrderHold
join SalesTable
where SalesTable.SalesId == OCSSalesOrderHold.SalesId
&& SalesTable.DocumentStatus == DocumentStatus::Invoice
&& OCSSalesOrderHold.Status == Status ::Held;
ttscommit
}0 -
Which version of AX it is?
Use an Exists Join...Kranthi0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions