When to use FIND('=<>')

Vineeth.RVineeth.R Member Posts: 121
Dear Friends

When should we use FIND('=><')????? cant we use FIND('-') instead? please advise when specifically we should

if Record.FIND('=><') then
Thanks and Regards
Vineeth.R

Comments

  • garakgarak Member Posts: 3,263
    The '=' mean, find first a record which is qual.
    If not equal rec is found,search for a record which is smaller '<'
    If a smaller rec is not found, search for a bigger rec '>'.
    So, 3 querys for one needed result set.
    Mostly it's used to "say" find anything (mean is there some rec in the filter).
    For this it's better to use Isempty. And if you realy need the Data use findfirst or findset for a loop.

    Regards
    Do you make it right, it works too!
  • Vineeth.RVineeth.R Member Posts: 121
    Dear Garak,

    can i replce the FIND('=<>') with Find('-') ?

    thanks and Regards
    vineeth.R
    Thanks and Regards
    Vineeth.R
  • garakgarak Member Posts: 3,263
    the question is, what you want do to?
    and what for a server u use (native or sql)
    Do you make it right, it works too!
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Vineeth.R wrote:
    Dear Friends

    When should we use FIND('=><')????? cant we use FIND('-') instead? please advise when specifically we should

    if Record.FIND('=><') then

    Its very important to know the history of this construct before making that decision. But to cut to the chase, on SQL there is no need normally to use this (use FINDSET instead). On Native it probably is not useful with modern hardware use FIND('-') instead.

    The use of this construct came about because of the way that the Navision cache interacted directly with hard disks. (I will analogize here, so don't take the following as hard facts).

    Basically the idea is that you have a hard drive (with latency), you have a controller (with cache), you have a Native serve (with cache) and you have a client (with cache) and the idea was that if it was not important to retrieve records in a particular sequence, then best would be to find the first one that fits your requirements so the structure says if the current record contained in the current record one that I can use? if so use it, if not then start seeking till you find the next record in my filter set. If you reach the end and find nothing, then go back to where we started from and start searching backwards. Of course Find('-') would be the equivalent of if you found using the last parameter, ('<').

    This command is particularly good if you are using marks, since marks are very inefficient and thus every bit helps, also if you have very broken filters it helps a lot, but if you have a very clean filter, e.g. you are searching the GL entry table by filtering on Document No. (with the correct key) then there is no value, you might as well use FIND('-').

    now remember that this structure came about when a 1 gig database was considered as BIG, and 486 meant a high end server. With modern hardware, I personally believe that the added complexity is not worth it.

    A couple of notes.
    Typically in SQL if you were processing a record set and did not care about the processing order, then you would not select a key and you would use FINDSET, in this case you are letting SQL so the equivalent of FIND('=><');
    It should be noted that ISEMPTY is almost never a replacement for FIND('=><') ISEMPTY does not return any records, and is only used if you want to know if there is a record there. It should never be used if the intention is to then process the records in the set.
    David Singleton
  • idiotidiot Member Posts: 651
    In other words, it is incongruous in this time & age to see something like FIND('=><'), there's no denying that Navision is old...
    Having said that, it would interesting to view the improvements if old codes like FIND('-') were replaced with FINDSET/FIRST, ISEMPTY, coupled with the correct key...
    NAV - Norton Anti Virus

    ERP Consultant (not just Navision) & Navision challenger
  • kinekine Member Posts: 12,562
    if old codes like FIND('-') were replaced with FINDSET/FIRST, ISEMPTY, coupled with the correct key...

    But you cannot only blindly replace all FIND('-') with FINDFIRST... I hope that you know that. FIND('-') is not dead, it is still used and there are good reasons why to use it instead FINDFIRST or FINDSET...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • idiotidiot Member Posts: 651
    kine wrote:
    But you cannot only blindly replace all FIND('-') with FINDFIRST... I hope that you know that. FIND('-') is not dead, it is still used and there are good reasons why to use it instead FINDFIRST or FINDSET...

    Can you give any good examples on why FIND('-') should be not replaced in 4.01 & above in SQL with proper SETCURRENTKEY?
    NAV - Norton Anti Virus

    ERP Consultant (not just Navision) & Navision challenger
  • David_SingletonDavid_Singleton Member Posts: 5,479
    idiot wrote:

    Can you give any good examples on why FIND('-') should be not replaced in 4.01 & above in SQL with proper SETCURRENTKEY?

    :shock: this is scary.

    I really hope that you are not going intoo customers code and just randomly/globally replacing one structure with another.

    Did it occur to you that if there was one piece of code that could just replace FIND('-') then they would have jsut done that at compile time.

    This is exactly why I keep saying that there will always be work for people like me fixing up after disasters like these. ](*,)
    David Singleton
  • WaldoWaldo Member Posts: 3,412
    You should be glad, then :wink:.

    What might be helpful is one of my previous blogposts: What impact does my C/AL have on SQL?

    Or the entire series: http://dynamicsuser.net/blogs/waldo/archive/tags/What+impact+does+my+C_2F00_AL+have+on+SQL/default.aspx

    And if you don't want to leave Mibuso for this (which I entirely understand :mrgreen: ): http://www.mibuso.com/forum/viewtopic.php?f=33&t=23675&hilit=What+impact+does+my+C%2FAL+have+on+SQL

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • idiotidiot Member Posts: 651

    :shock: this is scary.

    I really hope that you are not going intoo customers code and just randomly/globally replacing one structure with another.

    Did it occur to you that if there was one piece of code that could just replace FIND('-') then they would have jsut done that at compile time.

    This is exactly why I keep saying that there will always be work for people like me fixing up after disasters like these. ](*,)

    I do not know how to do things randomly so I'm asking for examples of why & when FIND('-') should not be replaced with more efficient codes.
    Navision was not built for SQL initially so a lot of codes were not optimized for SQL. Furthermore new versions were always enhancements of existing codes which nobody really dared to touch to optimize.

    Glad that there's always work for both of us then. :D
    NAV - Norton Anti Virus

    ERP Consultant (not just Navision) & Navision challenger
Sign In or Register to comment.