cursor c1 is select id,a,b,c from table1;
r1 c1%rowtype;
cursor c2 is select id,x,y,z from table2 where id=r1.id;
r2 c2%rowtype;
然后先fetch第一个游标,在循环中fetch第二个游标

解决方案 »

  1.   

    也可以用变量啊,在程序体中用变量接收第一个游标fetch的值,然后再open第二个游标
      

  2.   

    请看程序如下:if TABLE_SEND%isopen then
           close TABLE_SEND;
      end if;
      open TABLE_SEND;
      loop
          fetch TABLE_SEND into RecRowSend ;
          exit when TABLE_SEND%notfound;
          if(cu_pro%isopen) then
                close cu_pro;
          end if;
          sqlSendSub:= 'Select oid from ' || RecRowSend.mTbName || ' where nvl(trflag,''N'')!=''Y''';
          open cu_pro for sqlSendSub;
          loop
            fetch cu_pro Into li_Recordid;
            exit when cu_pro%notfound;
            if(li_Recordid  is not null) then 
                p_mq_send(RecrowSend.mTbName,'OID',li_Recordid,RTN_CODE,RTN_MSG);
                -- 如果写入成功 ,更新状态位
                if(RTN_CODE='0') then
                 sqlSendSub:= ' delete from ' || RecRowSend.mTbName || '  where oid=' || li_Recordid ;
                   execute immediate sqlSendSub;
                   commit;
                end if;
            end if;
          end loop;
          if(cu_pro%isopen) then
                close cu_pro;
          end if;
      end loop;