Parameters 如何探索PLSQL块中的out cursor参数?

Parameters 如何探索PLSQL块中的out cursor参数?,parameters,plsql,cursor,out,Parameters,Plsql,Cursor,Out,我需要验证一个具有out cursor参数的过程。具体地说,我需要查看正在检索的内容 我试试这个: declare type cursor_out is ref cursor; cur cursor_out; fila activ_economica%rowtype; procedure test(algo out cursor_out) is begin open algo for select * from activ_economica; end; b

我需要验证一个具有out cursor参数的过程。具体地说,我需要查看正在检索的内容

我试试这个:

declare
  type cursor_out is ref cursor;
  cur cursor_out; 
  fila activ_economica%rowtype;
  procedure test(algo out cursor_out) is
  begin
    open algo for select * from activ_economica;  
  end;
begin
  test(cur);
  for i in cur loop
    fila := i;
    dbms_output.put(fila.id_activ_economica ||' ' );
    dbms_output.put_line(fila.nom_activ_economica);
  end loop;
end;

错误在于未定义“cur”。

不能将cursor FOR循环与ref cursor一起使用,必须执行以下操作:

declare
  type cursor_out is ref cursor;
  cur cursor_out; 
  fila activ_economica%rowtype;
  procedure test(algo out cursor_out) is
  begin
    open algo for select * from activ_economica;  
  end;
begin
  test(cur);
  loop
    fetch cur into fila;
    exit when cur%notfound;
    dbms_output.put(fila.id_activ_economica ||' ' );
    dbms_output.put_line(fila.nom_activ_economica);
  end loop;
  close cur;
end;
注意:不再需要定义自己的ref游标类型(除非您使用的是非常旧的Oracle版本)。您只需使用SYS\u REFCURSOR即可:

declare
  cur sys_refcursor; 
  ...

很好,我找了很多,但什么也找不到,你帮我省了一天的工作:D