December 2002
Intermediate to advanced
928 pages
85h 29m
English
When using a single trigger for multiple events, use the trigger predicates INSERTING, UPDATING, and DELETING in the trigger condition to identify the triggering event. The following example illustrates the use of trigger predicates:
CREATE OR REPLACE TRIGGER emp_log_t
AFTER INSERT OR UPDATE OR DELETE ON emp
FOR EACH ROW
DECLARE
dmltype CHAR(1);
BEGIN
IF INSERTING THEN
dmltype := 'I';
INSERT INTO emp_log (emp_no, who, operation)
VALUES (:new.empno, USER, dmltype);
ELSIF UPDATING THEN
dmltype := 'U';
INSERT INTO emp_log (emp_no, who, operation)
VALUES (:new.empno, USER, dmltype);
END IF;
END;