Statement is false, but it get executed like true

BlankNameBlankName Posts: 11Member
edited 2019-02-06 in NAV Three Tier
I want to check last prod. order no. vs current and if they are different input it into temp table. And statement in attached photo is false, but somehow it gets interpreted as true, when both prod.order no. are same. Why this is happening?
f3mfvhpk41b2.png

Answers

  • AlexDenAlexDen Posts: 16Member
    Hi,

    You check only first record.
    You have to move this check into the loop:
    IF TRH.FINDSET THEN
      REPEAT
        IF TRH."Production Order No." <> LastEntry THEN BEGIN
        ...
        END;
      UNTIL TRH.NEXT = 0;
    
  • BlankNameBlankName Posts: 11Member
    There is 2 loops and when it gets out of first loop I want to make that check in debugger window at right you can see those two variables being the same. And I get error when it tries to write to my temp table because record already exist and my statement lastentry <> prod order no. was accepted as true when in reality they are both same and it shouldn't be true.
  • AlexDenAlexDen Posts: 16Member
    Yes, I see.

    Your code will not work if there will be records like this:
    Order 1
    Order 2
    Order 1 // Last Entry = Order 2, bit Order 1 is already saved in temp table and you will get an error.


  • BlankNameBlankName Posts: 11Member
    AlexDen is right...
Sign In or Register to comment.