oracle创建触发器及作用举例

--创建触发器及作用举例
create or replace trigger tri
before delete on emp 
--在删除emp表数据之前需要做的事根据自己的业务去写,before是在之前做的事,after是在之后要做的事
declare
t_result number := 10;
begin
  dbms_output.put_line('admin' || t_result);
end tri;

--下面是对表某些字段进行更新之后做的操作
create or replace trigger TRI_DISPLAYTABLE
after update of datatype,dbcolumnname,name on P#GCFR_T_FACTOR
for each row
declare
errno number;
errmsg varchar2(30);
begin
if updating ('datatype') then
update GCFR_T_DISPLAYTABLE t set t.datatype = :new.datatype where t.viewname = :old.dbtablename
and t.isvirtualcolumn = 0 and t.columncode = :old.dbcolumnname;
end if;

if updating ('dbcolumnname') then
update GCFR_T_DISPLAYTABLE t set t.datatype = :new.datatype where t.viewname = :old.dbtablename
and t.isvirtualcolumn = 0 and t.columncode = :old.dbcolumnname;
end if;

if updating ('name') then
update GCFR_T_DISPLAYTABLE t set t.datatype = :new.datatype where t.viewname = :old.dbtablename
and t.isvirtualcolumn = 0 and t.columncode = :old.dbcolumnname;
end if;
end;

--删除触发器
drop trigger tri;

 

转载于:https://www.cnblogs.com/hkdpp/p/8301926.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值