Using a cursor variable in SQL*Plus

Below is a simple example of opening a cursor variable in SQL*Plus and then printing its contents.

DBA’s can use this if they are not PL/SQL proficient to do some simple test casing with developer cursor code.

SQL> variable b refcursor
SQL> begin
  2    open :b for select username from dba_users;
  3  end;
  4  /

PL/SQL procedure successfully completed.

SQL> print b

USERNAME
------------------------------
QIANH
HYPER_ACC1_0
HYPER_QRT3

...snip...

RMAN
ORDPLUGINS
SI_INFORMTN_SCHEMA

43 rows selected.

SQL>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.