Rec.FIND('=><')

RachelSoonRachelSoon Member Posts: 202
Hi All,
Anyone know what does the below statement mean?

Rec.FIND('=><')

I found this at T5606, function GetGenJnlDocumentNo.

Thank you.

Regards
Rachel

Comments

  • WaldoWaldo Member Posts: 3,412
    Straight from "help":
    This...
    Tells the system to search for...

    '='
    A record that equals the key values (default)

    '>'
    A record that is larger than the key values

    '<'
    A record that is less the key values

    '+'
    The last record in the table ('+' can only be used alone)

    '-'
    The first record in the table ('-' can only be used alone)

    If SearchStr contains '=', '>' or '<', you must assign values to all fields of the current and primary keys before you call FIND.
    so in your case, a record that equals, is larger or is less than that value :-k .

    Probably it has assigned values to all parts of the primary key ... may be you can add some more code to see what it does in this case?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • WaldoWaldo Member Posts: 3,412
    RachelSoon wrote:
    I found this at T5606, function GetGenJnlDocumentNo.
    Are you sure about the object? table 5606 is "FA Posting Group", and it dos not contain that function (in my db).
    What version are you using?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • RachelSoonRachelSoon Member Posts: 202
    Sorry, Waldo,
    It's T5605.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    RachelSoon wrote:
    Hi All,
    Anyone know what does the below statement mean?

    Rec.FIND('=><')

    I found this at T5606, function GetGenJnlDocumentNo.

    Thank you.

    Regards
    Rachel

    REC.FIN('=><'); is a function designed to optimize the process of finding the first record in a record set in the Navision Native database (if setup correctly). Its actually left over from the DOS days, and personally I doubt its value these days, and now I always replace it with the new command FINDFIRST.

    Basically the way it work is this:

    If you have already accessed any record int he current filter set, then that record would normally still be in cache, so the "=" will return that cached record without needing a disk access. This means you can start your processing immediately. Basically this is saying "we have a record in a variable that has the same primary key, but maybe the other fields have been changed so let's just go and refresh from the database.

    The next thing, is to look at the quickest record to find next. Now so long as you followed the rules, and built Navision on multiple RAID 1 drives, (and not raid 10 or 5) then Navision will have tried to write the records sequentially as they were created across multiple drives, so the logic is that since the spindles are spinning in a forward direction, and assuming you have optimized spin latency.Then the next record in the current set will be found using the ">" command.

    If none of those are found, then the system will find the record that is stored first on the drive with "<".

    But today with intelligent disk controllers it really makes no sense. Today we let the hardware people worry about all that stuff. So just think that if you see Navision use the code, then in 99.9% of cases it can be replaced with FINDFIRST.

    In reality though, maybe a better command might be FINDANY, but I can't see that its worth it.
    David Singleton
  • WaldoWaldo Member Posts: 3,412
    I have a side remark with that.

    Use FINDFIRST when you actually need that data of that record.
    If you don't need data and you only want to see if there is a record for that filter, use ISEMPTY.
    If you're going to loop the data, use FINDSET or FIND('-') (if the set is probably over 500 records)

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Waldo wrote:
    I have a side remark with that.

    Use FINDFIRST when you actually need that data of that record.
    If you don't need data and you only want to see if there is a record for that filter, use ISEMPTY.
    If you're going to loop the data, use FINDSET or FIND('-') (if the set is probably over 500 records)


    Yes sorry, you are right, FINDSET is generally probably the correct replacement in most cases, not FINDFIRST.
    David Singleton
  • RachelSoonRachelSoon Member Posts: 202
    Hi All,
    Thank you for the clarifications.

    Regards
    Rachel
Sign In or Register to comment.