在创建
compound trigger
你应该想想你想做什么。每个
复合触发器
可以拆分为多个
triggers
. 如果你有多重
触发器
在一
table
,这就是要考虑的一点
复合触发器
,将这些功能合并为一个
trigger
。
这是toad为其创建的默认模板
Compound triggers
-解释得很好:
COMPOUND TRIGGER
tmpVar NUMBER;
BEFORE STATEMENT IS
BEGIN
begin
-- we cannot reference :new or :old in the before statement section
tmpVar := 0;
EXCEPTION
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END;
END BEFORE STATEMENT;
BEFORE EACH ROW IS
BEGIN
begin
-- we can read or write to :new or :old in the before each row section
tmpVar := 0;
EXCEPTION
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END;
END BEFORE EACH ROW;
AFTER EACH ROW IS
BEGIN
begin
tmpVar := 0;
-- we can read, but not write to :new or :old in the after each row section
EXCEPTION
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END;
END AFTER EACH ROW;
AFTER STATEMENT IS
BEGIN
begin
-- we cannot reference :new or :old in the after statement section
tmpVar := 0;
EXCEPTION
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END;
END AFTER STATEMENT;
END MyTrigger;