Implementation of triggers
Date: 27 Apr 1993 23:57:20 GMT
Message-ID: <1rkh90$34q_at_menudo.uh.edu>
This a question regarding implementation of triggers. My understanding of the
triggers is that they are executed as part of the transaction generating the
triggering event.
I will give an example first and then present my questions.
I am using pseudo language to define triggers and its actions.
CREATE TRIGGER delete_trigger ON titles FOR {DELETE} IF DELETE primary_key THEN DELETE all_foreign_key IN DEPENDENT TABLES
Now lets say a transaction UPDATE_TITLES is executed and this deletes some title_id's (primary_key) from the table "titles", then the above trigger gets fired and deletes all occurences of the deleted primary_key's in all DEPENDENT TABLES.
My question is when are the actions performed by the trigger "delete_trigger" commited: as soon as the trigger finishes executing?? or at the commit of transaction UPDATE_TITLES which caused the trigger to fire.
Logically, if the trigger is executed as a part of the transaction causing it to fire, then its actions should be commited only at the commit of the transaction, otherwise the final result will be an inconsistant state. In the above example this would happen if the trigger actions are commited and the the transaction UPDATE_TITLES aborts.
If my initial assumption that triggers are executed as a part of the transaction causing the triggering event is wrong, then my question is how is the execution of triggers modeled??
Summarizing: The questions I have are:
- If the triggers are executed as part of the transaction causing the triggering event, when do the actions performed by triggers get commmited?
- If triggers are not executed as a part of the transaction causing the triggering event, then how is their execution modeled??
I would appreciate any replies to my email address.
Thanks
Sridhar Ganti
ganti_at_cs.uh.edu
Received on Wed Apr 28 1993 - 01:57:20 CEST