3、只对整个表执行一次。2、举例:下面的触发器在更新表auths之前触发,目的是不允许在周末修改表:create triggerauth_secure before insert or update or delete //对整表更新前触发on authsbeginif(to_char(sysdate,'DY')='SUN'RAISE_APPLICATION_ERROR(-20600,'不能在周末修改表auths');end if;end例子:CREATE OR REPLACE TRIGGER CRM.T_SUB_USERINFO_AUR_NAME AFTER UPDATE OF
4、 STAFF_NAMEON CRM.T_SUB_USERINFOREFERENCING OLD AS OLD NEW AS NEWFOR EACH ROWdeclarebeginif :NEW.STAFF_NAME!=:OLD.STAFF_NAME thenbegin客户投诉 update T_COMPLAINT_MANAGE set SERVE_NAME=:NEW.STAFF_NAME where SERVE_SEED=:OLD.SEED;客户关怀update T_CUSTOMER_CARE set EXECUTOR_NAME=:NEW.STAFF_NAMEwhere EX
5、ECUTOR_SEED=:OLD.SEED;客户服务 update T_CUSTOMER_SERVICE set EXECUTOR_NAME=:NEW.STAFF_NAMEwhere EXECUTOR_SEED=:OLD.SEED;end;end if;end T_sub_userinfo_aur_name;/Oracle触发器语法(三)二Oracle触发器详解开始:create triggerbiufer_employees_department_idbeforeinsertorupdateofdepartment_idonemployeesreferencingoldas
6、old_value newasnew_valuefor each rowwhen (new_value.department_id<>80 )begin:new_value.commission_pct :=0;end;/1、触发器的组成部分:1、触发器名称2、触发语句3、触发器限制4、触发操作1.1、触发器名称create trigger biufer_employees_department_id命名习惯:biufer(before insert update for each row)employees表名department_id列名1.2、触发语句比如:表或视图上的
7、DML语句DDL语句Oracle触发器语法(四)数据库关闭或启动,startupshutdown等等before insert or updateof department_idon employeesreferencing old as old_valuenew as new_valuefor each row说明:1、无论是否规定了department_id,对employees表进行insert的时候2、对employees表的department_id列进行update的时候1.3、触发器限制w