您好,登錄后才能下訂單哦!
在一個存儲過程中有兩個游標,而且第二個游標用到了第一個游標的值,這樣的存儲過程怎么寫呢?以下是個例子:
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。