Subject Re: [firebird-support] accessing data from the trigger & ON DELETE CASCADE
Author Ann W. Harrison
At 11:00 AM 12/5/2004, Valentin Samko wrote:

>I have found a bug in my program where a few database tables are not
>updated properly due to Firebird unable to access certain data from
>the trigger.

A foreign key with "on delete cascade" causes the delete of the
parent before it begins deleting related records from the child
table. A before delete record in the child executes after the
parent is gone.

>I do not know whether this is the expected behaviour or not, and if it
>is configurable (I really hope so).

Yes, it's expected and no, it's not configurable, directly. You
could change your implementation so a before delete trigger in the
parent table deletes the related records in the child table. In
general, such triggers are less reliable than equivalent constraints
but in this case the triggers have two advantages. First, they do
what you want. Second, you can do both - define both a before
delete trigger on the parent table and an "on delete cascade" foreign
key relationship between the tables.



Regards,


Ann