Best way to copy filtered table data to temp table?

Steve
Member Posts: 81
We have to copy several "real" tables in temp for processing. Currently we are Navi 5.1 - SQL 2005.
We have several options, but I was looking for the most efficient and fastest method in Navision code.
1.
Table.SETRANGE(Field,Filter);
...
If Table.FINSET(FALSE,FALSE) THEN
REPEAT
TempTable.COPY(Table);
TempTable.INSERT;
UNTIL Table.NEXT=0;
2.
Table.SETRANGE(Field,Filter);
...
If Table.FINSET(FALSE,FALSE) THEN
REPEAT
TempTable.Field1 := Table.Field1;
....
TempTable.INSERT;
UNTIL Table.NEXT=0;
Any ideas would be appreciated. I guess these are the only 2 methods, but with the number of tables moving to temp I wanted to make sure I'm doing this the best method possible within Navision.
Thanks
We have several options, but I was looking for the most efficient and fastest method in Navision code.
1.
Table.SETRANGE(Field,Filter);
...
If Table.FINSET(FALSE,FALSE) THEN
REPEAT
TempTable.COPY(Table);
TempTable.INSERT;
UNTIL Table.NEXT=0;
2.
Table.SETRANGE(Field,Filter);
...
If Table.FINSET(FALSE,FALSE) THEN
REPEAT
TempTable.Field1 := Table.Field1;
....
TempTable.INSERT;
UNTIL Table.NEXT=0;
Any ideas would be appreciated. I guess these are the only 2 methods, but with the number of tables moving to temp I wanted to make sure I'm doing this the best method possible within Navision.
Thanks
Steve
0
Comments
-
do you need all the fields of the record, or a limited subset? if you need all of them, i would think method 1 is the better bet. if you only need a few fields, you may be better off with the second.
that's my thought - not knowing what you are ultimately trying to do.
edit: :oops:
yes yes. not COPY but temprec := rec.kind of fell into this...0 -
All depends on if the temp table is same table as the source table, only defined as temporary. If yes, you can use only
TempRec := Rec; TempRec.INSERT;
If they are different, but the fields have same IDs, you can useTempRec.TRANSFERFIELDS(Rec); TempRec.INSERT;
If they are totally different, you can use your second example. The first one have bigger overhead, because the COPY function copy filters and other things too...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