NAV 5.00 SQL problem with INSERT(TRUE)

I was just working on testing a system in 5.00. The following code works fine in 4.00:

IF DefaultDim.DELETE(TRUE) THEN

;

but in 5.00 gives an error message “The Default Dimension xyz does not exist”. Well I know it doesn’t but that should be handled by the IF. The database

Now the code:

IF DefaultDim.GET(DefaultDim.“Table ID”,DefaultDim.“No.”,DefaultDim.“Dimension Code”) THEN

DefaultDim.DELETE(TRUE);

And it works fine in both 4.00 and 5.00.

Also the code

IF DefaultDim.DELETE THEN

;

Does not give the error, but I can’t use that.

To me what it looks like, is that in 4.00 the execution is terminated as soon as the database says that the record does not exist, so the IF catches the error, and continues. But in 5.00 the OnDelete trigger is run even though the record does not exist. So it gets into the OnDelete, and finds an error in there since there is no record.

From the programmers view I think that is an error in the implementation of the OnDelete trigger. But I think MS will sell us this as a feature…

Thank you for the hint.

Well, a “get more work”-feature is always welcome …NOT
And then I bet they change it back in 5.1 (a “Get even more work”-feature)[8-)]

David the below code works the same in 2.6, 3.7,4.0 as well as 5.0.

IF record.DELETE(TRUE) THEN;

They all error based on the ondelete trigger code even if the record doesn’t exists.

That’s not the point. The point IS that the code on the OnDelete-trigger of the dimension management give that error; as David said:

No. his point is

And I said that the execution is not terminated if the record does not exist. It never did.

plus why would you have code in the ondelete trigger to the delete the record you are trying to delete?

Looks to me like a modification, because I can’t replicate it in Standard 5.0.

Why? Because there IS code on the OnDelete trigger. What is the problem with code on that trigger. David just want to make sure that the “OnDelete code” will be executed (DefaultDim.DELETE(TRUE) he wrote). So the OnDelete trigger is run in 5.0 even though the record does not exist (which won’t in 4.x)

It will in 4.x. Have you tried it?

I will try this evening.

That’s because there are times you need to do cascade delete. For example, you wouldn’t want to delete a record in a header table without deleting its lines (see any header and line table).

Could you give a standard Navision example?

Check out table 5767.

I posted a thread here: http://www.mibuso.com/forum/viewtopic.php?t=22800