1. Compound trigger makes it easier to program an approach where you want the actions you implement for the various timing points to share common data.
To achieve the same effect with simple triggers, you had to model the common state with an ancillary package
2. Compound triggers to avoid the mutating-table error
Ref. http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/triggers.htm#CHDFEBFJ
CREATE OR REPLACE TRIGGER compound_trigger
COMPOUND TRIGGER
-- Declarative part (optional)-- Variables declared here have firing-statement duration.threshold CONSTANT SIMPLE_INTEGER := 200;
BEFORE STATEMENT IS BEGIN NULL; END BEFORE STATEMENT;
BEFORE EACH ROW IS
BEGIN NULL;
END BEFORE EACH ROW;
AFTER EACH ROW IS
BEGIN NULL;
END AFTER EACH ROW;
AFTER STATEMENT IS BEGIN NULL; END AFTER STATEMENT;
END compound_trigger;
The database executes all triggers of the same type before executing triggers of a different type.
If you have multiple triggers of the same type on the same table, and the order in which they execute is important, use the FOLLOWS clause.
No comments:
Post a Comment