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.
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)
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).