ITPub博客

首页 > 数据库 > Oracle > ORACLE触发器

ORACLE触发器

原创 Oracle 作者:oraclesuperman 时间:2015-06-04 16:11:56 0 删除 编辑
create or replace trigger tr_sal_change
after update of sal on emp1
for each row
  declare
   v_temp int;
   begin
     Select Count(1) into v_temp From audit_emp_change where name=:old.ename;
     if v_temp=0 then
     insert into audit_emp_change values (:old.ename,:old.sal,:new.sal,sysdate);
      --commit;
      else
        update audit_emp_change
        set oldsal = :old.sal,newsal= :new.sal,time=sysdate
        where name=:old.ename;
       -- commit;
        end if;
        end;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29313086/viewspace-1685778/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2015-03-20

  • 博文量
    178
  • 访问量
    422834