web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

FindFrst & Find('-')

(0) ShareShare
ReportReport
Posted on by 3,099

Hi

  What is the difference between FindFrst & Find('-').

Thanks

*This post is locked for comments

I have the same question (0)
  • Verified answer
    ManishS Profile Picture
    86 on at
    RE: FindFrst & Find('-')

    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.

  • Verified answer
    Binesh Profile Picture
    7,885 on at
    RE: FindFrst & Find('-')

    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

  • ManishS Profile Picture
    86 on at
    RE: FindFrst & Find('-')

    Performance of Findfirst will decrease in repeat until loop.

  • Community Member Profile Picture
    on at
    RE: FindFrst & Find('-')

    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:

    Customer.RESET;

    IF Customer.FINDFIRST THEN

     REPEAT

       MyInteger += 1;

     UNTIL Customer.NEXT = 0;

    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...

  • Suggested answer
    Suresh Kulla Profile Picture
    50,237 Super User 2025 Season 2 on at
    RE: FindFrst & Find('-')

    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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Alexander Ermakov Profile Picture

Alexander Ermakov 2

#2
SC666 Profile Picture

SC666 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans