create or replace procedure aa is
   procedure bb is
     type mycursor is ref cursor;
     my_cursor mycursor;
     begin
        open my_cursor for select * from cc;
        loop
        fetch my_cursor into ...;
        exit when my_cursor%notfound;
        ...;
        end loop;
        
     end bb;
begin
    ...
end aa;

解决方案 »

  1.   

    为什么这样不行??for tem in my_cursor loop
    另外
    如果在声明部分:
    cursor UPLOG is select * from table;要用uplog的话,不能open和close
    open uplog;    errors:already open
    ..
       for tem in uplog loop
    ..
    close uplog    errors:invalid cursor请问是什么原因??
      

  2.   

    示例一:
    declare
    cursor UPLOG is select * from table;
    begin
    open uplog
    loop
    fetch uplog into ...;
    exit when uplog%notfound;
    ...
    end loop;
    close uplog;
    end;
    /
    示例二:
    declare
    type mycursor is ref cursor;
    my_cursor mycursor;
    begin
    open my_cursor for select * from table;
    loop 
    fetch my_cursor into ...;
    exit when my_cursor%notfound;
    ...;
    end loop;
    close my_cursor;
    end;
    /
    两者相同作用