oracle 触发器及游标的使用
create or replace trigger tri_salary
after insert on salary
for each row
declare
id varchar2(8);
name varchar2(8);
salary number(8);
cursor cur is select seq_salary.nextval as seq from dual;
cursor log is select salary from salary_log where salary_log.name = name;
mylog log%rowtype;
myseq cur%rowtype;
begin
id:= :new.id;
name:= :new.name;
salary:= :new.salayry;
open cur;
open log;
fetch cur into myseq;
if log%notfound then
insert into salary_log values(myseq.seq,id,name,salary);
else
fetch log into mylog;
insert into salary_log values(myseq.seq,id,name,mylog.salary);
end if;
close log;
close cur;
end ;