Options

ERROR Behavior Guess what happens

mikmik Member Posts: 79
edited 2011-10-07 in NAV Three Tier
Hi,
I have a little example code. Maybe many of you know this but for me it was quite new.

Cust (Record Customer)
Vend (Record Vendor)
Cust.INIT;
Cust."No." := 10000;
Cust.INSERT;

Cust.INIT;
Cust."No." := 10000;
Cust.INSERT;

Message('Customer Insert worked great!\Well done!');
// or any other code without database transaction

Vend.INIT;
Vend."No." := 10000;
Vend.INSERT;

Compare 5.XX or lower with 6.01 R2 Build 32XXX

Even if you try to compile you will notice that there is a difference between 5.xx and 6.01 R2 (or maybe also lower)

The ERROR must occur after the second insert. Normaly the code stops here!? Not in 6.01 R2.
Can someone please verify this and tell me if this is an official behavior?


greetings
mik

With kind regards
mik

Answers

  • Options
    BeliasBelias Member Posts: 2,998
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    mikmik Member Posts: 79
    Hi,

    thanks now its clear but changes a lot for developers.

    http://msdn.microsoft.com/en-us/library/dd355341.aspx

    Thanks Belias!

    With kind regards
    mik
  • Options
    BeliasBelias Member Posts: 2,998
    You're welcome.
    anyway, i don't see so much difference for the developers except that you have to be "smart" when you debug (you have to forecast the behaviour of the bulk inserts).
    It is a cool feature to give a boost to the insert performance, in some instances...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • Options
    mikmik Member Posts: 79
    Hi,
    you are right. But sometimes it was quite comfortable to let NAV run into an error so you do not have to catch every single case.
    I noticed this error because of database operations where after these operations files have been operated. This shocked me quite a lot. So it seems that my coding is quite ok because of the fact that I haven't noticed this befor. But my research is quite bad so I haven't seen this msdn article before ](*,)
    Thanks again

    With kind regards
    mik
  • Options
    krikikriki Member, Moderator Posts: 9,090
    Give the same code a try with the debugger. The error will come at the 2nd insert, because debugging disables the bulk-insert feature.
    Also IF rec.INSERT THEN ... disables the bulk-insert
    and also if you use the autoincrement=Yes in the table.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Options
    mikmik Member Posts: 79
    No thats the point. The debugger will handle the complete code and after the last line he will show the error from the second insert. Only with
    IF cust.Insert ....
    
    or Commit or your autoincrement (never tried) the debugger will stop when the error occurs.
    Thats way i said .. "good to know" :idea:

    With kind regards
    mik
Sign In or Register to comment.