Temporary table in NAV

I recently found a very interesting blog post about temporary tables by Vjekoslav Babic. It explains really good the different ways a temporary table is handled when used as a parameter . You can basically call a method with a table by value or by reference. When you are using by value the data in the table is copied to a new variable and when you are using by reference you are actual using the same variable as the calling method. This work as expected when not using temporary tables. When it comes to temporary tables you may get an unexpected behavior when using the “by reference”.

Here is an example
temporary table example

The “ByRefereceWrong” will actual delete all records if you are passing a none temporary record to it. A fixed version with verification can be found in “ByRefence” where we use record reference and the ISTEMPORARY method.

Vjekoslav blog post found here does cover some other problem areas as “phantom insert”. I would recommend reading the complete post.

0.00 avg. rating (0% score) - 0 votes

About Peter Wibeck

Comments

2 Responses to “Temporary table in NAV”
  1. edd says:

    I discovered this ‘feature’ after I accidentally passed a non temporary table to a function expecting a temporary table (ended up deleting all records in the real table, thankfully only in Cronus DB!). Was googling for a way to prevent this happening in the future and this is a perfect solution, thanks!

    edd

Trackbacks

Check out what others are saying about this post...
  1. […] Bron : Peter Wibeck’s blog Lees meer… […]



Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!

*