Compound Trigger
In Oracle 11g, the concept of compound trigger was introduced. A
compound trigger is a single trigger on a table that enables you to specify
actions for each of four timing points:
1. Before the firing
statement
2. Before each row
that the firing statement affects
3. After each row that
the firing statement affects
4. After the firing
statement
With the compound trigger,
both the statement-level and row-level action can be put up in a single
trigger. Plus there is an added advantage: it allows sharing of common state
between all the trigger-points using variable.
CREATE OR
REPLACE TRIGGER
compound_trigger_name
FOR [INSERT|DELETE]UPDATE [OF column] ON table
COMPOUND TRIGGER
-- Declarative Section (optional)
-- Variables declared here have firing-statement
duration.
--Executed before DML statement
BEFORE STATEMENT IS
BEGIN
NULL;
END
BEFORE STATEMENT;
--Executed before each row change- :NEW, :OLD are
available
BEFORE EACH ROW IS
BEGIN
NULL;
END
BEFORE EACH ROW;
--Executed aftereach row change- :NEW, :OLD are
available
AFTER
EACH ROW IS
BEGIN
NULL;
END AFTER
EACH ROW;
--Executed after DML statement
AFTER
STATEMENT IS
BEGIN
NULL;
END AFTER
STATEMENT;
END compound_trigger_name;
Comments