Immediate insertion through codeunit

sabzamsabzam Member Posts: 1,149
Dear All,

I have got 1000 records whcih are to be inserted one after the other. But I would like that even if there is an error in record 400 the 399 records (i.e. the records before the error) are inserted.

Is this possible?

Comments

  • HalMdyHalMdy Member Posts: 429
    I assume you have some code like :
    REPEAT
               Rec.Field1 := ...
               Rec.Field2 := ...
               Rec.INSERT(TRUE);
             UNTIL ...
    

    In place of making a unconditionnal Insert, make something like :
    IF NOT Rec.INSERT(TRUE) THEN ... (put info in a lock)
    

    Hope that help.
  • kinekine Member Posts: 12,562
    You will need to call commit after each insert to end the transaction and insert the next record in another transaction.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • sendohsendoh Member Posts: 207
    u can commit every 100 record

    IF ((iCtr MOD 100) = 0) THEN
    COMMIT;
    Sendoh
    be smart before being a clever.
  • sabzamsabzam Member Posts: 1,149
    Hi It has worked fine. Thanks for your reply
Sign In or Register to comment.