- 第一次写触发器,浪费了一个小时,少了一个;编译不通过
当A表有更新或插入数据时,则触发器执行向B表插入对应条件的数据
1 CREATE OR REPLACE TRIGGER Test -- 触发器名称 - 2 AFTER update or insert on table --AFTER 指定 触发时间,on后跟表名称,即当表table有更新或者插入时触发时间
- 3 for each row
- 4
- 5 DECLARE
- 6 columName VARCHAR2(20); --定义变量
- 7
- 8
- 9 columName :=:new.columNam; --根据当前数据更新变量
- 10
- 11 Begin
- 12 IF col ='1' then
- 13 insert into table1 (co1,co2) VALUES(:new.co1,'co2');
- 14 END IF;
- 15 IF col ='1' then
- 16 insert into table1 (co1,co2) VALUES(:new.co1,'co2');
- 17 END IF;
- 18 End;