Options

findset(true,true)

garakgarak Member Posts: 3,263
hy everybody,

when i use findset(true,true) i ask the system, that i will rename the primary key fields. Now my question. For which Pk is this :?:

The primary Navision Key (Key 1) or the clustered key for the sql server :?:

Regards
Do you make it right, it works too!

Comments

  • Options
    WaldoWaldo Member Posts: 3,412
    Afaik,

    When using FINDSET(TRUE,TRUE), you specify you will modify the currentkey. This could be the primary key, but it could be one of the secondary keys as well... .

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    DenSterDenSter Member Posts: 8,304
    It is intended to be used for records sets that you intend to modify values for fields that you used to filter the record set on. So if you set a filter on a certain customer, with the intent of changing the customer, you set the parameter to TRUE. It is used for setting the correct isolation level, so that when you do change the field value, you don't lose your place in the current record set, which could be the case before we got the parameter.
  • Options
    krikikriki Member, Moderator Posts: 9,098
    DenSter wrote:
    It is intended to be used for records sets that you intend to modify values for fields that you used to filter the record set on. So if you set a filter on a certain customer, with the intent of changing the customer, you set the parameter to TRUE. It is used for setting the correct isolation level, so that when you do change the field value, you don't lose your place in the current record set, which could be the case before we got the parameter.
    But it is always better to put the record in another variable, and change it in that variable.
    I read somewhere that you can also use FINDSET(FALSE,FALSE) and do it and it will work well, but it will be less efficient.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    DenSterDenSter Member Posts: 8,304
    I don't know if it is better, I have not done any comparison. I do know that they included this parameter specifically to enable us to modify filtered fields within the same record set. If that would come at a performance price that would not surprise me.

    In smaller loops I don't really think it will make much of a difference, but in larger ones it might. I'd say start out with the easy one and if you have performance issues you introduce more complexity.
  • Options
    batmakibatmaki Member Posts: 11
    hi all,

    take a look on my code. i can't understand what is wrong...
    LProdOrderLine.RESET;
    LProdOrderLine.SETFILTER("Prod. Order No.",'2007*');
    LProdOrderLine.SETFILTER("Line No.",'<99100&>99000|<100');
    IF LProdOrderLine.FINDSET(TRUE,TRUE) THEN BEGIN
      REPEAT
        LProdOrderLine2 := LProdOrderLine;
        IF LProdOrderLine."Line No." < 100 THEN
          LProdOrderLine2."Line No." := LProdOrderLine2."Line No." * 10000;
        IF LProdOrderLine."Line No." > 99000 THEN
          LProdOrderLine2."Line No." := LProdOrderLine2."Line No." * 10;
        LProdOrderLine2.MODIFY;
      UNTIL LProdOrderLine.NEXT = 0;
      COMMIT;
    END;
    

    i get an error on LProdOrderLine2.MODIFY saying that the record doesn't exist.

    help please!
    thanks in advance[/code]
  • Options
    WaldoWaldo Member Posts: 3,412
    Are you trying to modify the primary key?
    don't use modify, use "rename" for that...

    Modify tries to modify a record BASED on a primary key ... which you changed, so it doesn't exist :| make any sense?

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    MbadMbad Member Posts: 344
    Waldo wrote:
    make any sense?

    /nod
  • Options
    WaldoWaldo Member Posts: 3,412
    Nod?
    :-k

    Dictionary:
    to express or signify by such a movement of the head: to nod approval; to nod agreement.

    So I guess you agree :wink:

    Eric Wauters
    MVP - Microsoft Dynamics NAV
    My blog
  • Options
    MbadMbad Member Posts: 344
    /nod :)
Sign In or Register to comment.