Creating Triggers  «Prev 

Trigger Firing Sequence in Oracle

Just like a gun, firing a trigger requires that you first create the trigger, load it into the database, and define the target. (the event that causes it to be fired). In the example shown here, a user has created three rows that are to be inserted into a table in the database. The application sends the three rows as a set(transaction) to the database for processing. The system designer has created four triggers which fire when data is inserted into the table.

Looking at the activity inside the database, the system begins by inserting the first of three rows [ARS] into the table. The action fires two triggers: one trigger before any insert transaction, then one trigger before inserting the first row. Then the row is actually inserted into one table. Finally, a third trigger is fired after inserting the row.

The second row is sent to be inserted. This fires one trigger before and one trigger after inserting the row.

The third and final row fires one trigger before the row is inserted . Then the row is inserted and two triggers are fired. 1) One after the row is inserted and one that only fires after the full set of rows has been inserted. 2) The same sequence of events can be implemented for updates and deletes of rows as well.