create or replace trigger trigger_pdgyqdlxx
after insert or update or delete on pd_gyqdlxx
for each row
begin
if inserting then
insert into pd_gyqdlxx_tmp(oldgyqbh,gyqbh,gyqmc,action) values('',:new.gyqbh,:new.gyqmc,'insert')
elseif updating then
insert into pd_gyqdlxx_tmp(oldgyqbh,gyqbh,gyqmc,action) values(:old.gyqbh,:new.gyqbh,:new.gyqmc,'update')
elseif deleting then
insert into pd_gyqdlxx_tmp(oldgyqbh,gyqbh,gyqmc,action) values(:old.gyqbh,'','','delete')
end if;
end;
after insert or update or delete on pd_gyqdlxx
for each row
begin
if inserting then
insert into pd_gyqdlxx_tmp(oldgyqbh,gyqbh,gyqmc,action) values('',:new.gyqbh,:new.gyqmc,'insert')
elseif updating then
insert into pd_gyqdlxx_tmp(oldgyqbh,gyqbh,gyqmc,action) values(:old.gyqbh,:new.gyqbh,:new.gyqmc,'update')
elseif deleting then
insert into pd_gyqdlxx_tmp(oldgyqbh,gyqbh,gyqmc,action) values(:old.gyqbh,'','','delete')
end if;
end;
elsif 可以不用,就if then endif多好,清晰.
在执行 delete from pd_gyqxx where gyqbh='b'得时候
报 触发器 'YXZDH.TRIGGER_PDGYQDLXX' 无效且未通过重新确认
不知道怎么才能正确啊
2 before insert or update or delete on tableA
3 for each row
4 begin
5 if inserting then
6 insert into b values (:new.id);
7 end if;
8 if updating then
9 update b set id = :new.id where id = old.id;
10 end if;
11 if deleting then
12 delete from b where id = old.id;
13 end if;
14 end;
比着改
after insert or update or delete on pd_gyqdlxx
for each row
begin
if inserting then
insert into pd_gyqdlxx_tmp(oldgyqbh,gyqbh,gyqmc,action) values('',:new.gyqbh,:new.gyqmc,'insert')
elsif updating then
insert into pd_gyqdlxx_tmp(oldgyqbh,gyqbh,gyqmc,action) values(:old.gyqbh,:new.gyqbh,:new.gyqmc,'update')
elsif deleting then
insert into pd_gyqdlxx_tmp(oldgyqbh,gyqbh,gyqmc,action) values(:old.gyqbh,'','','delete')
end if;
end;