Reference cursor type : refcursor « Cursor « Oracle PL/SQL Tutorial






SQL>
SQL> create table t ( x varchar2(5) );

Table created.

SQL>
SQL> declare
  2      type rc is ref cursor;
  3      l_cursor rc;
  4  begin
  5      for i in 1 .. 5000
  6      loop
  7          open l_cursor for 'select x from t where x = ' || to_char(i);
  8          close l_cursor;
  9      end loop;
 10  end;
 11  /

PL/SQL procedure successfully completed.

SQL>
SQL> declare
  2      type rc is ref cursor;
  3      l_cursor rc;
  4  begin
  5      for i in 1 .. 5000
  6      loop
  7          open l_cursor for 'select x from t where x = :x' using i;
  8          close l_cursor;
  9      end loop;
 10  end;
 11  /

PL/SQL procedure successfully completed.

SQL>
SQL> drop table t;

Table dropped.

SQL>
SQL>








25.15.refcursor
25.15.1.reference cursor variable
25.15.2.Reference cursor type
25.15.3.return sys_refcursor from a function