Dear Friends,
I am using Nav4.0 SP3 and i found something funny.
USE FINDFIRST Result is wrong
vInt := 0;
Table1.reset;
Table1.setrange(field1,value);
Table1.setrange(field2,value);
if Table1.FINDFIRST then begin
message('%1',Table1.count); //Count shows 8
repeat
vInt += 1;
until Table1.next = 0;
message('%1', vint); // vint is 5
end;
USE FIND('-') working fine
vInt := 0;
Table1.reset;
Table1.setrange(field1,value);
Table1.setrange(field2,value);
if Table1.FINDFIRST then begin
message('%1',Table1.count); //Count shows 8
repeat
vInt += 1;
until Table1.next = 0;
message('%1', vint); // vint is 8
end;
Please advise why this funny scenario..
thanks and Regards
Vineeth.R
Thanks and Regards
Vineeth.R
0
Comments
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Nav set a sql query like this:
To get a resultset use findset([ForUpdate][, UpdateKey]) or find('-') (find('-') with locktable if many datachanges in the loop self)
If you only need to know, exist there some datas in the table based on my filters use MyRecTableAsVariable.ISEMPTY.
Here NAV create a sql query like this
Regards
Sorry i forgot to highlight FIND('-') please see again:
USE FINDFIRST Result is wrong
vInt := 0;
Table1.reset;
Table1.setrange(field1,value);
Table1.setrange(field2,value);
if Table1.FINDFIRST then begin
message('%1',Table1.count); //Count shows 8
repeat
vInt += 1;
until Table1.next = 0;
message('%1', vint); // vint is 5
end;
USE FIND('-') working fine
vInt := 0;
Table1.reset;
Table1.setrange(field1,value);
Table1.setrange(field2,value);
if Table1.FIND('-')then begin
message('%1',Table1.count); //Count shows 8
repeat
vInt += 1;
until Table1.next = 0;
message('%1', vint); // vint is 8
end;
Please advise why this funny scenario..
Dear Garak,
So you mean when ever i need to loop i have to go for FINDSET or FIND('-') in lower versions right? can u guess why i got vInt as 5 in the second scenario here.?
thanks and Regards
Vineeth.R
Vineeth.R
I might suggest that you read it ... 8)
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I investigated that in the article above ... off course I would like your opinion on this .
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
I mean it in the intentions you have wrote. There can be dependency of "optimal" usage on record count and man need to know that. If it will have really measurable impact or not is another question.
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
So in your case, you are going to loop through the records, so you need to use FINDSET. Depending on whether you are going to modify these records, and even modify fields that are part of the filter, you need to set the right parameter values. See the C/SIDE reference guide for more details.
You should really not use FIND('-') anymore.
RIS Plus, LLC
MVP - Business Apps