SETFILTER 'NOT IN' QUESTION

Soloper
Member Posts: 102
Hi all;
I have two tables (lets say TABLE1 and TABLE2) and need a set of records from TABLE1.
TABLE1 has a field named "ID", TABLE2 has fields named "ID", "FIELDA" and "FIELDB".
The mission is that :
I need all IDs from TABLE1 except some filtered IDs from TABLE2.
The code looks like as following;
TABLE2.RESET;
TABLE2.SETFILTER("FIELDA",'BLABLA');
TABLE2.SETFILTER("FIELDB",'BLABLA');
IF TABLE2.FIND('-') THEN
BEGIN
TABLE1.RESET;
TABLE1.SETFILTER("ID", NOT IN TABLE2."ID")
...
SOME LOOP
...
...
END;
I know the underlined part has a syntax error. I Just want to show what I am trying to do.
Thanks you all for your help.
I have two tables (lets say TABLE1 and TABLE2) and need a set of records from TABLE1.
TABLE1 has a field named "ID", TABLE2 has fields named "ID", "FIELDA" and "FIELDB".
The mission is that :
I need all IDs from TABLE1 except some filtered IDs from TABLE2.
The code looks like as following;
TABLE2.RESET;
TABLE2.SETFILTER("FIELDA",'BLABLA');
TABLE2.SETFILTER("FIELDB",'BLABLA');
IF TABLE2.FIND('-') THEN
BEGIN
TABLE1.RESET;
TABLE1.SETFILTER("ID", NOT IN TABLE2."ID")
...
SOME LOOP
...
...
END;
I know the underlined part has a syntax error. I Just want to show what I am trying to do.
Thanks you all for your help.
0
Comments
-
Any suggestion?
Or should I try it with temp table?
Thanks.0 -
You can do it with a temporary table or the MARK-functionality. The process would be the same, so I descripe it with the MARK.
You can MARK(true) all records in the first table using a loop. Then filter the second table like you want and loop through the second table. In every loop you filter the record in the first table equal to your ID of the second tables record. If a record will be found in table one then set MARK(FALSE) (DELETE when using the temporary table solution). At the end only those records in table 1 are marked which had no ID in the second table. You can filter the result using MARKEDONLY on the first table.0
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