Hi
What is the difference between FindFrst & Find('-').
Thanks
*This post is locked for comments
Findfirst will retrieve one records at a time from the database, were as find('-') will reterive a set of records from the server, save it in you memory(cache) of the PC you are using and will show records accordingly.
Find('-') is basically used with repeat until loop and findfirst is not.
See, Solution is re-modified on the suggestion of #Manish Sharma, #Nabil BA-MOH, #Suresh Kulla,
FINDFIRST vs FIND('-')
FIND('-') Use this function to find a record in a C/SIDE table based on the values stored in keys.
FIND function has capability to find in different- different ways.
FINDFIRST - Use this function to find the first record in a table based on the current key and filter.
Example:
-------- In This Case you will get the data but performance is down,
Si if we require set of records then we use FINDSET or FIND('-')
CLEAR(MyInteger);Customer.RESET;IF Customer.FINDFIRST THEN REPEAT MyInteger += 1; UNTIL Customer.NEXT = 0;MESSAGE('MyInteger: %1', MyInteger);
CLEAR(MyInteger1);Customer.RESET;IF Customer.FIND('-') THEN REPEAT MyInteger1 += 1; UNTIL Customer.NEXT = 0;MESSAGE('MyInteger1: %1', MyInteger1);
For More details Source - C/AL Database Functions and Performance on SQL Server
Performance of Findfirst will decrease in repeat until loop.
Dear Binesh,
Excuse me but I don't agree with you when you say "In Both situation you will get same".
First of all, the behavior of FINDFIRST and FIND('-') depends on NAV version. The current behavior is described here: msdn.microsoft.com/.../dd355237(v=nav.70).aspx
If you use a loop then you should use FIND('-') or FINDSET:
Customer.RESET;
IF Customer.FIND('-') THEN
REPEAT
MyInteger1 += 1;
UNTIL Customer.NEXT = 0;
In the example below, you're killing performance:
IF Customer.FINDFIRST THEN
MyInteger += 1;
Because with FINDFIRST, NAV opens a connection to SQL Server and close it when the record (one record only) is retrieved. When you do Cusomer.NEXT, you ask again to open a connection, retrieve a record and close the connection...
When you use FIND('-'), NAV opens a connection and retrieve a set of records (based on statistics of the number of rows read), it stores it in cache then it closes the connection. When you call NEXT then NAV opens a new connection, retrieves a second set of records, etc...
Binesh,
I totally don't agree with you comment, people don't use it for fancy reason. Please read this and there are few other articles describing how it performs on SQL Server.
msdn.microsoft.com/.../dd355237(v=nav.90).aspx
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Alexander Ermakov 2
SC666 1