Oracle – How to Run the Procedure

oracleplsql

Here the Package..

CREATE OR REPLACE PACKAGE G_PKG_REFCUR AS
    TYPE rcDataCursor IS REF CURSOR;
END;

Let's consider the PROC..

Create procedure gokul_proc(
    pId in number,
    pName in varchar2,
    OutCur OUT G_PKG_REFCUR.rcDataCursor ) is
BEGIN
    Open OutCur For
        select * from gokul_table ob 
        where ob.active_staus-'Y' AND ob.id=pId AND ob.name=pNname;
END;

Here is my question: How can I execute this procedure?

If there isn't an OutCur parameter, then I can execute like this..

EXEC gokul_proc(1,'GOKUL');

but, the problem is OutCur. I don't know which value to pass here.

For example

EXEC gokul_proc(1,'GOKUL', ??????);

I just need to know what value to pass as a argument for the procedure.

Best Solution

In SQL Plus:

VAR rc REFCURSOR
EXEC gokul_proc(1,'GOKUL', :rc);
print rc