Not all records deleted

rixrixrixrix Member Posts: 121
Hello,

I tried to delete some OLD records in repeat/until loop.
While deleting I was checking the records count directly on DB by MSSMS ( select count(*) )
And I am observing this strange behavior : After one run it deletes some records (but not all it should). But when run another time , it deletes next bunch of records ... and so on

But there are no new recs for deletion - I filter for older than 1 year) - so I thought it will delete all in one loop

So only I can think about is that deleting in loop can be the problem. (cursors?) Or maybe that COMMITS ?
Can u help me with that?

There are Ondelete triggers on the records I delete

code:
loctSHAV.RESET;
loctSHAV.SETRANGE("Document Type",loctSHAV."Document Type"::Invoice);
loctSHAV.SETRANGE("Date Archived",0D,CALCDATE('<-1Y>',TODAY)); 
IF loctSHAV.FIND('-') THEN BEGIN
  locAktNo   := 'START';
  REPEAT
    locAktIsA := FALSE;

    IF locAktNo <> loctSHAV."No." THEN BEGIN
      locAktNo  := loctSHAV."No.";
      IF loctSHAV."Posting No." = '' THEN BEGIN
        loctSIH.RESET;
        loctSIH.SETCURRENTKEY("Pre-Assigned No.");
        loctSIH.SETRANGE("Pre-Assigned No.");
        IF NOT loctSIH.ISEMPTY THEN locAktIsA := TRUE ELSE locAktIsA := FALSE;
      END ELSE BEGIN
        IF loctSIH.GET(loctSHAV."Posting No.") THEN locAktIsA := TRUE ELSE locAktIsA := FALSE;
      END;
    END;

    IF (locAktIsA = TRUE) THEN BEGIN
      loctSHAV.DELETE(TRUE);
      COMMIT;
    END;

  UNTIL loctSHAV.NEXT = 0;
END;

Comments

  • imclever1205imclever1205 Member Posts: 94
    Did you try using FINDSET instead of FIndFIRST while perfoming your loop ?
  • rixrixrixrix Member Posts: 121
    Hi I just found that it is wrongly coded ....

    sorry for bothering

    delete post if possible
    Thank u
Sign In or Register to comment.