在一个存储过程中有两个游标,而且第二个游标用到了第一个游标的值,这样的存储过程怎么写呢?以下是个例子:
create or replace procedure DYNAMIC_CONFIRM
as
cursor c1 is select o.id,o.cno,o.icorpid,o.iroeid, o.lr from ccs os inner join cc o on os.ids= o.id where o.istate=3 ;
v c1%rowtype;//把游标c1查询值的类型赋值给v
cno varchar(15);
begin
open c1;
loop
fetch c1 into v;
exit when c1% notfound;
update fc set fc.ibalance = v.lr;
/* 声明游标2*/
DECLARE cursor c2 is SELECT ISMBID FROM FC_SECUMONEYB where FC_SECUMONEYB.IOUTCORPID=v.icorpid AND FC_SECUMONEYB.IDEPID=v.idepid;
v1 c2%rowtype;
begin //遍历第二个游标
open c2;
loop fetch c2 into v1;
exit when c2% notfound;
Insert Into FC_SECUMONEYR(IINCORPID,DDATE,IDEPID,ISETTLEBALANCE)Values(431,sysdate,v.idepid,v1.ISETTLEBALANCE) ;
end loop;
end;
end loop;
end;
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。