Translation of SQL statement to Navision syntax

idiot
Member Posts: 651
eg
SELECT [Document No_], SUM([Cost Amount (Actual)]) DocTotal
FROM [Cronus$Value Entry]
WHERE ([Posting Date] = '2007-01-01')
GROUP BY [Document No_]
What is the best translation for such a statement into Navision c/side?
Required analysis is the least cost or fastest time.
This is a an ad-hoc based selection.
Is there any more efficient way of doing other than this:
1. select all distinct Document No. & insert into temp table
2. loop through the temp table & for each Document No., loop through the Value Entry table again & sum based on the Document No.
SELECT [Document No_], SUM([Cost Amount (Actual)]) DocTotal
FROM [Cronus$Value Entry]
WHERE ([Posting Date] = '2007-01-01')
GROUP BY [Document No_]
What is the best translation for such a statement into Navision c/side?
Required analysis is the least cost or fastest time.
This is a an ad-hoc based selection.
Is there any more efficient way of doing other than this:
1. select all distinct Document No. & insert into temp table
2. loop through the temp table & for each Document No., loop through the Value Entry table again & sum based on the Document No.
NAV - Norton Anti Virus
ERP Consultant (not just Navision) & Navision challenger
ERP Consultant (not just Navision) & Navision challenger
0
Comments
-
valueentry.setrange("Posting Date",'whatever date'); if valueentry.findset then repeat tempvalueentry.setrange("Document No.",valueentry."Docment No."); if tempvalueentry.findfirst then begin tempvalueentry."Cost Amount (Actual)" += valueentry."Cost Amount (Actual)"; tempvalueentry.modify; end else begin tempvalueentry."entry No." := valueentry."Entry No."; tempvalueentry."Cost Amount (Actual)" := valueentry."Cost Amount (Actual)"; tempvalueentry.insert; end; until valueentry.next = 0;
0 -
Hi Rashed,
I hope you do not mind if I suggest an improved version of the code:
valueentry.setrange("Posting Date",'whatever date');
if valueentry.findset then
repeat
tempvalueentry.setrange("Document No.",valueentry."Docment No.");
if not tempvalueentry.findfirst then
begin
tempvalueentry.init;
tempvalueentry."Document No." := valueentry."Document No.";
tempvalueentry.insert;
end;
tempvalueentry."Cost Amount (Actual)" += valueentry."Cost Amount (Actual)";
tempvalueentry.modify;
until valueentry.next = 0;
The reason I think this is better is the fact that in your example the code for processing the temp record once you had it was written twice. So if you wanted to add to the code later you would need to write same thing in both places.
This way you only have one place you write it in.Apathy is on the rise but nobody seems to care.0 -
thanks. the init should be there.0
-
Thanks guys.
Guess this standard way is already the most efficient...NAV - Norton Anti Virus
ERP Consultant (not just Navision) & Navision challenger0
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
- 322 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