anonymous block for procedure-ref cursor out variable [message #187124] |
Fri, 11 August 2006 00:44 |
bhagat.singh-j
Messages: 39 Registered: April 2006
|
Member |
|
|
I've a procedure with a ref cursor type output variable.
Can someone help me with a anonymous block to invoke my procedure P_RET_REF_CURSOR and view each record of DEPARTMENT table
SQL> DESC DEPARTMENT
Name Null? Type
-------------------
DEPTNO NUMBER
ENAME VARCHAR2(200)
CREATE OR REPLACE PACKAGE l_ref_cursor
AS
TYPE rc IS REF CURSOR;
END;
CREATE OR REPLACE PROCEDURE P_RET_REF_CURSOR(lrc OUT l_ref_cursor.rc)
AS
BEGIN
OPEN lrc FOR 'SELECT * FROM DEPARTMENT';
END;
Thanks,
Bhags
|
|
|
Re: anonymous block for procedure-ref cursor out variable [message #187132 is a reply to message #187124] |
Fri, 11 August 2006 01:39 |
bhagat.singh-j
Messages: 39 Registered: April 2006
|
Member |
|
|
Got the answer.
from SQL plus do...
SQL> var rc refcursor;
SQL> exec p_ret_ref_cursor(:rc)
PL/SQL procedure successfully completed.
SQL> print :rc
DEPTNO ENAME
---------- -----------------------------------------------------
20 SMITH
20 SMITH
30 ALLEN
30 WARD
20 JONES
30 MARTIN
30 BLAKE
10 CLARK
20 SCOTT
10 KING
30 TURNER
20 ADAMS
30 JAMES
20 FORD
10 MILLER
15 rows selected.
|
|
|
|