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/
,如需转载,请注明出处,否则将追究法律责任。