码迷,mamicode.com
首页 > 数据库 > 详细

oracle触发器

时间:2015-12-31 12:50:17      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:

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触发器

标签:

原文地址:http://www.cnblogs.com/chenglongyi/p/5091161.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!