Order in Which Triggers Fire
If two or more triggers with different timing points are defined for the same statement on the same table, then they fire in this order:
-
All
BEFORE
STATEMENT
triggers -
All
BEFORE
EACH
ROW
triggers -
All
AFTER
EACH
ROW
triggers -
All
AFTER
STATEMENT
triggers
If it is practical, replace the set of individual triggers with different timing points with a single compound trigger that explicitly codes the actions in the order you intend. For information about compound triggers, see "Compound DML Triggers".
If you are creating two or more triggers with the same timing point, and the order in which they fire is important, then you can control their firing order using the FOLLOWS
and PRECEDES
clauses (see "FOLLOWS | PRECEDES").
If multiple compound triggers are created on a table, then:
-
All
BEFORE
STATEMENT
sections run at theBEFORE
STATEMENT
timing point,BEFORE
EACH
ROW
sections run at theBEFORE
EACH
ROW
timing point, and so forth.If trigger execution order was specified using the
FOLLOWS
clause, then theFOLLOWS
clause determines the order of execution of compound trigger sections. IfFOLLOWS
is specified for some but not all triggers, then the order of execution of triggers is guaranteed only for those that are related using theFOLLOWS
clause. -
All
AFTER
STATEMENT
sections run at theAFTER
STATEMENT
timing point,AFTER
EACH
ROW
sections run at theAFTER
EACH
ROW
timing point, and so forth.If trigger execution order was specified using the
PRECEDES
clause, then thePRECEDES
clause determines the order of execution of compound trigger sections. IfPRECEDES
is specified for some but not all triggers, then the order of execution of triggers is guaranteed only for those that are related using thePRECEDES
clause.Note:
PRECEDES
applies only to reverse crossedition triggers, which are described in Oracle Database Development Guide.
The firing of compound triggers can be interleaved with the firing of simple triggers.
When one trigger causes another trigger to fire, the triggers are said to be cascading. The database allows up to 32 triggers to cascade simultaneously. To limit the number of trigger cascades, use the initialization parameter OPEN_CURSORS
(described in Oracle Database Reference), because a cursor opens every time a trigger fires.