Filters and loops

tsv
Member Posts: 49
hi all,
can any one tell me whether the following code is upto standard and would increase the performance or iam wrong
am using SQL
and can i use the setcurrentkey in loops like this?
Thanks inadvance
can any one tell me whether the following code is upto standard and would increase the performance or iam wrong
am using SQL
if Table1.find('-') then repeat Table2.reset; Table2.setcurrentkey(No.,Type,Amount); Table2.setrange(No.,Table1.No.); Table2.setrange(Type,Table1.Type); Table2.setrange(Amount,Table1.Amount); if Table2.find('-') then repeat //some code that would update another table, say table3 until Table2.next = 0; until table1.next = 0;
and can i use the setcurrentkey in loops like this?
Thanks inadvance
with regards,
tsv
tsv
0
Comments
-
hi Belias,
They are pointing to different tables.with regards,
tsv0 -
1) Native DB or SQL?
2) If SQL, you do not need the SetCurrentkey if you do not need to go through the table in some predefined order. (it will only add sorting process to the set, if you remove it, it will be sorted by primary key)0 -
Thanx for the suggestion Kamil...
am using SQL. My primary key is "No.", along with the primary field i need to setrange for two more fields
(type, Amount). Will it increase the performance by sorting Table1 with three fields( No., type, Amount) as given in the above code.. Table1 and 2 is having lakhs of records.
Thanks in advancewith regards,
tsv0 -
if you have this key "No., type, Amount" and "maintainsqlindex" property of the Key = true
you don't need to use setcurrentkey function, unless you need to order your dataset result (as said in kine's 2nd point)0 -
tsv wrote:Thanx for the suggestion Kamil...
am using SQL. My primary key is "No.", along with the primary field i need to setrange for two more fields
(type, Amount). Will it increase the performance by sorting Table1 with three fields( No., type, Amount) as given in the above code.. Table1 and 2 is having lakhs of records.
Thanks in advance
As Belias wrote, the Setcurrentkey have no effect to which key will be used (not directly), it is adding only "ORDER BY" clausule to the resulting SQL query, and SQL is sorting the result as last thing. Which key will be used is on the SQL planning system...0 -
if you have this key "No., type, Amount" and "maintainsqlindex" property of the Key = true
you don't need to use setcurrentkey function, unless you need to order your dataset result (as said in kine's 2nd point)
"No., type, Amount" is not my primary key...
do i have to keep this as my primary key.with regards,
tsv0 -
tsv wrote:if you have this key "No., type, Amount" and "maintainsqlindex" property of the Key = true
you don't need to use setcurrentkey function, unless you need to order your dataset result (as said in kine's 2nd point)
"No., type, Amount" is not my primary key...
do i have to keep this as my primary key.
but it must exist as secondary key if you want to order your data like this...(SETCURRENTKEY returns error if the key does not exist)
0 -
thanx Belias and kine , i understoodwith regards,
tsv0
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