Not all records deleted

rixrix
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:
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;
0
Comments
-
Did you try using FINDSET instead of FIndFIRST while perfoming your loop ?0
-
Hi I just found that it is wrongly coded ....
sorry for bothering
delete post if possible
Thank u0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions