Subject Re: On Delete Cascade
Author Sandor Szollosi <>

> Ok, I see that BeforeDelete/AfterDelete are triggered in detail
> table when I do a delete on master table, and the FK action is On
> Delete Cascade. And that when I do an update in the master PK
> field, if On Update Cascade action is used, the corresponding field
> in detail table will be update accordingly.
> But, when I do a delete to the master table, it seems that the
> master record is deleted, and after that, the correspondig detail
> records will be deleted, in that order. Is that true?

By my experiencies works this way.

> My problem was that in detail AfterDelete trigger, I was trying to
get a
> value from a join involving the master table. And I was always
getting a
> null value. I've concluded that master record was deleted before
the detail.
> I was expecting a behavior similar to an update, when the master is
> and after that the detail is updated.
> The delete shouldn't behave like the update?

To my mind when the detail Before/AfterDelete trigger run, the master
table doesn't contain the master record.

Let assume us the delete order would run vica versa (step1: delete
from detail, step2: from master).
For example 1000 record in detail belong to the record in master.
If another FK points to record in master(in 2 detail table),
disabling to delete it, this error will shown after deleting the 1000
detail record.