oracle触发器

create or replace trigger test_trigger
after insert or update or delete on pf_service_order
for each row
declare
info varchar2(20);
begin
if inserting then
info:='insert操作';
elsif updating then
info:='update操作';
else
info:='delete操作';
end if;
insert into test_info values(info);
end test_trigger;
/


create or replace trigger test_trigger
after insert or update or delete on pf_service_order
for each row
declare
info varchar2(20);
begin
if inserting then
info:='insert操作';
elsif updating then
info:='update操作';
else
info:='delete操作';
end if;
insert into test_pf_service_order(so_id,order_id,area_id,info) values(:new.so_id,:new.order_id,:new.area_id,info);
end test_trigger;
/

 

create or replace trigger test_trigger
after update on test_pf_service_order
for each row
declare
info varchar2(20);
begin
if updating then
insert into test_info ti values(:new.area_id,:old.area_id);
end if;
end test_trigger;
/

(一定要注意 :new :old只能在行级触发器才能使用)

你可能感兴趣的:(oracle触发器)