首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

关于两层游标的用法的疑问,该如何解决

2012-05-23 
关于两层游标的用法的疑问一直用sqlserver,没有用过oracle,现在写了个存储过程,用两层游标,语法有问题?还

关于两层游标的用法的疑问
一直用sqlserver,没有用过oracle,现在写了个存储过程,用两层游标,语法有问题?还是oracle不能这么写?


代码;
 create or replace procedure updatetime is 

  v_jtdid NUMBER;
 v_audittaskid VARCHAR2(10);

cursor cursor1 is select * from (select jd.jtdid from tz_jobtypedetail jd where jd.jtid = 1001 order by jd.orderno ) where rownum < 5 ;


 
begin

open cursor1;
fetch cursor1 into v_jtdid;
while cursor1%found loop
begin


 

CURSOR cursor2 is select * from ( select a.audittaskid,a.creattime,a.orderdate,a.releasedate from tz_audittaskrelease a where a.categoryid = v_jtdid order by trunc(dbms_random.value(0, 1000))) where rownum < 13;

begin
  open cursor2;
  fetch cursor2 into v_audittaskid;
  while cursor2%found loop
  begin
  update tz_audittaskrelease set creattime = sysdate ,orderdate = sysdate ,releasedate = sysdate where audittaskid = v_audittaskid;
  end
  fetch cursor2 into v_audittaskid;  
end loop;
close cursor2;
end;


fetch cursor1 into v_jtdid;  
end;
end loop;

close cursor1;

end;


[解决办法]
把CURSOR cursor2 is select * from 的定义拿到Cursor1和begin之间定义。

热点排行