Oracle数据库多事件触发器,在Trigger Body中判断具体事件,举例:
1 create or replace trigger secure_emp 2 before 3 insert or update or delete on cux_employees 4 5 begin 6 if (to_char(SYSDATE,'DY') IN ('星期六','星期日')) or (to_char(SYSDATE,'HH24') NOT BETWEEN '08' AND '18') then 7 if deleting then 8 raise_application_error(-20502,'You may delete from EMPLOYEES table only during business hours.'); 9 elsif inserting then 10 raise_application_error(-20500,'You may insert into EMPLOYEES table only during business hours.'); 11 elsif updating('salary') then 12 raise_application_error(-20503,'You may update SALARY only during business hours.'); 13 else 14 raise_application_error(-20504,'You may update EMPLOYEES table only during normal hours.'); 15 end if; 16 end if; 17 end;
补充:
Oracle触发器产生冲突问题(ORA-04091)的解决方案参考文档:https://wenku.baidu.com/view/a6d40c2bbd64783e09122b7d.html