Subject Re[4]: [firebird-support] accessing data from the trigger & ON DELETE CASCADE
Author Valentin Samko
IP> Here is good explanation:

IP> To: firebird-support@yahoogroups.com
IP> From: "Alexander V.Nevsky" <ded@...>
IP> Date: Wed, 20 Aug 2003 08:57:51 -0000
IP> Subject: [firebird-support] Re: On delete cascade and before delete triggers

IP> Calin, no, it is right behaviour. It prevents the next situation,
IP> which will occure if check of details existance will be performed
IP> before master delete:

IP> 1. Transaction 1 started delete process
IP> 2. Transaction 1 checked existance of details and delete them
IP> 3. Transaction 2 inserted new detail for this master record
IP> 4. Transaction 1 deleted master and commited

IP> moment of transaction 2 commit is not principial, we have broken
IP> references integrity. Current behaviour (master deleted first)
IP> guarantees that transaction 2 can't insert detail during cascade
IP> delete process.

This does not explain why FB can not mark the master record for deletion
in (1) to prevent Transaction 2 from inserting a new detail for that
record. I am still wondering, how other DB's behave in this case, I will
investigate this later.

Valentin Samko
http://val.samko.info