Home » SQL & PL/SQL » Client Tools » Executing a procedure which has a cursor as an 'OUT' parameter
Executing a procedure which has a cursor as an 'OUT' parameter [message #249107] Tue, 03 July 2007 07:15 Go to next message
hannah.kamali
Messages: 10
Registered: July 2007
Location: Banglaore
Junior Member
Hi All,

I am trying to call a certain procedure which has a cursor as an 'OUT' parameter in the following manner:

DECLARE
FLID NUMBER;
SEARCH_RESULTS REF CURSOR;
ERR_CODE NUMBER;
ERR_MSG VARCHAR2(200);

BEGIN
FLID := NULL;
ERR_CODE := NULL;
ERR_MSG := NULL;

PACKAGE_NAME.PROCEDURE_NAME( FLID,
SEARCH_RESULTS, ERR_CODE, ERR_MSG );
COMMIT;
END;

But I get the error message as "PLS-00201: identifier 'CURSOR' must be declared". But it is clearly evident that I am defining the cursor here.

I am pretty new to PL/SQL, so senior folks, please help!
Re: Executing a procedure which has a cursor as an 'OUT' parameter [message #249113 is a reply to message #249107] Tue, 03 July 2007 07:36 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Welcome to the board and welcome to the world of Oracle!

"ref cursor" is not a datatype you can use like that in pl/sql.
If you search the documentation at tahiti.oracle.com for "ref cursor" you will no doubt find good examples on how to do this.
Re: Executing a procedure which has a cursor as an 'OUT' parameter [message #249116 is a reply to message #249113] Tue, 03 July 2007 07:40 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Just to add a little extra info: if you do a describe of the package, you will see the exact data type of the parameters in the procedure.

MHE
Re: Executing a procedure which has a cursor as an 'OUT' parameter [message #249119 is a reply to message #249113] Tue, 03 July 2007 07:42 Go to previous messageGo to next message
hannah.kamali
Messages: 10
Registered: July 2007
Location: Banglaore
Junior Member
Frank,

Thanks for your quick turn-around..
I will graze over the documentation and see if I can get a solution..
Re: Executing a procedure which has a cursor as an 'OUT' parameter [message #249130 is a reply to message #249107] Tue, 03 July 2007 08:00 Go to previous messageGo to next message
hannah.kamali
Messages: 10
Registered: July 2007
Location: Banglaore
Junior Member
Hey all,

I've found a solution for this and it works! You can find it below,

DECLARE
FLID NUMBER;
TYPE R_CUR IS REF CURSOR;
SEARCH_RESULTS R_CUR;
ERR_CODE NUMBER;
ERR_MSG VARCHAR2(200);

BEGIN
FLID := NULL;
ERR_CODE := NULL;
ERR_MSG := NULL;

PACKAGE_NAME.PROCEDURE_NAME(FLID, SEARCH_RESULTS, ERR_CODE, ERR_MSG );
COMMIT;
END;

But I'm not sure if this an optimal solution..or there is some other solution for the same..
Please comment..

Frank & Maaher, thanks for your valuable suggestions..
Re: Executing a procedure which has a cursor as an 'OUT' parameter [message #249133 is a reply to message #249107] Tue, 03 July 2007 08:14 Go to previous messageGo to next message
hannah.kamali
Messages: 10
Registered: July 2007
Location: Banglaore
Junior Member
People,

One more small help.

Can someone please make me aware of how to see the output of this kind of a procedure through TOAD.

I am doubtful because the output contains a CURSOR along with normal outputs.

Any pointers would be highly appreciated.
Re: Executing a procedure which has a cursor as an 'OUT' parameter [message #251569 is a reply to message #249119] Sat, 14 July 2007 18:08 Go to previous message
William Robertson
Messages: 1640
Registered: August 2003
Location: London, UK
Senior Member
A generic weak ref cursor is already defined for you, so you can just use

search_results SYS_REFCURSOR;

rather than going through the whole TYPE x IS REF CURSOR thing each time you want one.
Previous Topic: Sqlplus and Arabic characters
Next Topic: Connecting VB to a database created with SQL Developer
Goto Forum:
  


Current Time: Sat Dec 10 04:58:43 CST 2016

Total time taken to generate the page: 0.09247 seconds