oracle 触发器及游标的使用
2009-04-13 00:13
411 查看
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 ;
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 ;
相关文章推荐
- Oracle 触发器中使用游标
- oracle使用游标 触发器的存储过程
- [oracle] 触发器使用教程和命名规范
- 利用navicat创建存储过程、触发器和使用游标的简单实例
- oracle 游标使用
- Oracle 游标使用大全(二)
- Oracle 触发器使用
- Oracle 游标使用大全
- Oracle使用序列和触发器实现自增ID
- Oracle中游标Cursor的使用
- Oracle 游标使用全解
- oracle - 使用触发器创建自增列
- oracle游标使用示例
- Oracle游标使用参考语句
- oracle 游标使用
- Oracle 游标使用大全【转】
- Oracle 游标使用全解
- 转 Oracle 游标使用全解
- Oracle 游标使用大全
- oracle游标使用大全