Subject Re: [ib-support] Trigger Order (correct question)
Author Valdir Stiebe Junior
Thanks Brian, now i understand what is happening.
But it looks strange, like an inconsistency, because at the point where my
trigger try to run the query, the detail record is without a master. That's
why i think that the CHECKxx trigger that delete the details should be fired
between the "before delete master" and "delete master".
Anyway, thanks.

----- Original Message -----
From: "Brian K. Woods" <brian@...>
To: <>
Sent: Wednesday, February 05, 2003 1:30 PM
Subject: RE: [ib-support] Trigger Order (correct question)

> Valdir,
> The answer: because the deletion of the detail record is happening AFTER
> the deletion of the Master.
> If you look under the covers, creating a foreign key reference with delete
> action CASCADE also
> creates an AFTER DELETE trigger position 1. (you can see this using
> IBExpert or similar db managers, but you
> may have to look at the individual field's dependencies to see the trigger
> listed, at least for IBExpert)
> As you should relealize, AFTER means the master record is long gone.
> For your query in the AFTER delete trigger of the detail record to work,
> you would have to change the details record's foreign key delete action to
> handle the deletion of the detail records yourself in a BEFORE delete
> trigger on the
> Master record.
> So, for your situation, the actual order of events is:
> Master Before delete triggers fire
> **master record deleted here**
> master after delete triggers fire,
> one of which is a hidden CHECKxx trigger that deletes all detail records
> for the master record
> each of these detail deletions causes:
> Detail before delete triggers fire
> **detail record deleted**
> detail after delete triggers fire
> -wherein your after delete trigger tries to run a query
> the master that was deleted way back in the
> event sequence
> HTH,
> Brian
> To unsubscribe from this group, send an email to:
> Your use of Yahoo! Groups is subject to