refcursor varible : variable « SQL Plus « Oracle PL / SQL






refcursor varible

    
SQL>
SQL>
SQL> set echo on
SQL>
SQL> create table t as select * from all_users;

Table created.

SQL>
SQL> variable x refcursor
SQL>
SQL> begin
  2     open :x for select * from t;
  3  end;
  4  /

PL/SQL procedure successfully completed.

SQL>
SQL> delete from t;

14 rows deleted.

SQL>
SQL> commit;

Commit complete.

SQL>
SQL> print x
USERNAME                          USER_ID CREATED
------------------------------ ---------- --------------------
JAVA2S                                 44 13-JUN-2008 20:30:45
FLOWS_020100                           35 07-FEB-2006 22:52:43
FLOWS_FILES                            34 07-FEB-2006 22:52:43
HR                                     33 07-FEB-2006 22:51:21
MDSYS                                  32 07-FEB-2006 22:44:47
ANONYMOUS                              28 07-FEB-2006 22:40:15
XDB                                    27 07-FEB-2006 22:40:14
CTXSYS                                 25 07-FEB-2006 22:38:38
DBSNMP                                 23 07-FEB-2006 22:35:21
TSMSYS                                 20 07-FEB-2006 22:27:15
DIP                                    18 07-FEB-2006 22:17:03
OUTLN                                  11 07-FEB-2006 22:10:24
SYSTEM                                  5 07-FEB-2006 22:10:13
SYS                                     0 07-FEB-2006 22:10:13

14 rows selected.

SQL>
SQL> drop table t;

Table dropped.

SQL>
SQL> --

   
    
    
  








Related examples in the same category

1.Save returning value from a function to a variable
2.Define variable and print its value out
3.Define variable and set value
4.Define variable and use it in sql statement
5.Bind variables can be declared in your SQL*Plus script,Preface a bind variable with a colon to reference it in a PL/SQL block
6.Bind variables can even be referenced by SQL queries
7.Undefine variable
8.User defined-variable in update set statement