关于Oracle游标的一些项目中遇到的逻辑问题
作者:网络转载 发布时间:[ 2014/6/25 15:54:11 ] 推荐标签:软件开发 数据库 Oracle
正确的写法很多种,这里我以设置带参数的游标为例,将2个游标建立关系,再进行遍历不会出现问题。
如下:
|
create or replace procedure myt
as
cursor te_v1 is
select id1,val1 from Temp1;
cursor te_v2(idv2 varchar2) is
select count(*) from temp2 where id2=idv2;
v1_t te_v1%rowtype;
numv varchar2(2);
begin
open te_v1;
loop
fetch te_v1 into v1_t;
exit when te_v1%notfound;
open te_v2(v1_t.id1);
fetch te_v2 into numv;
if numv=0
then
update TEMP1 set val1='0' where id1=v1_t.id1;
else
update TEMP1 set val1='1' where id1=v1_t.id1;
end if;
close te_v2;
end loop;
close te_v1;
end;
|
ok,这种问题我们应该注意到
本文内容不用于商业目的,如涉及知识产权问题,请权利人联系SPASVO小编(021-61079698-8054),我们将立即处理,马上删除。

sales@spasvo.com