您好,登錄后才能下訂單哦!
在一個(gè)存儲過程中有兩個(gè)游標(biāo),而且第二個(gè)游標(biāo)用到了第一個(gè)游標(biāo)的值,這樣的存儲過程怎么寫呢?以下是個(gè)例子:
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;//把游標(biāo)c1查詢值的類型賦值給v
cno varchar(15);
begin
open c1;
loop
fetch c1 into v;
exit when c1% notfound;
update fc set fc.ibalance = v.lr;
/* 聲明游標(biāo)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 //遍歷第二個(gè)游標(biāo)
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;
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。