Discussion:
Calling a stored procedure that returns a cursor
solmyr72
2006-12-28 10:52:33 UTC
Permalink
Hi,

I'm new to Toad.
I have a stored procedure which returns a 'ref cursor' as an 'out'
parameter.
Is it possible to call such a procedure from TOAD, and make TOAD show the
table data which is represented by this cursor ?

For example, suppose my procedure is:

TYPE rf_cursor IS REF CURSOR;
procedure myProcedure(crs OUT ref_cursor) IS
BEGIN
open rf_cursor for
select * from PRODUCTS;
END

For this example, i'd like to invoke this procedure from TOAD, and see my
entire PRODUCTS table (because that's what my cursor points to).


Thanks very much !
--
View this message in context: http://www.nabble.com/Calling-a-stored-procedure-that-returns-a-cursor-tf2889770.html#a8073225
Sent from the Oracle TOAD mailing list archive at Nabble.com.
Werner Fangmeier
2007-01-02 09:29:16 UTC
Permalink
Hi,

TOAD's debugger has support for REF CURSORs, but AFAIK only for
"Strongly Typed" RCs, that have been declared in a package:

create or replace package rc_pkg is
type products_cursor_t is ref cursor return products%rowtype;
end;

create or replace procedure MyProc(
p_cur out rc_pkg.products_cursor_t
) is
begin
open p_cur for select * from products;
end;

Within a TOAD editor, you can now call the procedure from another
procedure:

create or replace procedure TestMyProc as
v_cur rc_pkg.products_cursor_t
begin
MyProc(v_cur);
end;

Then, compile this proc with debug information, invoke Debugger; set a
and have TOAD stop AFTER the call to "MyProc()". Now the Desktop Panel
"REF CURSOR Results" should show the REF CURSOR currently open, ready
for doing a FETCH with the "Refresh" function. You should then see a
grid containing the rows the cursor returns. Since I haven't done it
myself yet, I can't tell you exactly what you would see.

As you see, you need to license TOAD's Debugger feature to use the
"REF CURSOR Results" view. Otherwise, you have to write an anonymous
block doing a FETCH loop and output the columns with
DBMS_OUPUT.PUT_LINE(), or - even better - execute the SELECT statement
in Editor and view the results in the Grid or Output Views.
Post by solmyr72
Hi,
I'm new to Toad.
I have a stored procedure which returns a 'ref cursor' as an 'out'
parameter.
Is it possible to call such a procedure from TOAD, and make TOAD show the
table data which is represented by this cursor ?
TYPE rf_cursor IS REF CURSOR;
procedure myProcedure(crs OUT ref_cursor) IS
BEGIN
open rf_cursor for
select * from PRODUCTS;
END
For this example, i'd like to invoke this procedure from TOAD, and see my
entire PRODUCTS table (because that's what my cursor points to).
Thanks very much !
--
http://www.nabble.com/Calling-a-stored-procedure-that-returns-a-cursor-tf2889770.html#a8073225
Post by solmyr72
Sent from the Oracle TOAD mailing list archive at Nabble.com.
Ed Klinger
2007-01-02 14:39:31 UTC
Permalink
Yes this is possible but I believe you will need the debugger option according
to the Toad Help.

Here is an example - I created this package....

create or replace package mypkg as
TYPE csr IS REF CURSOR;
--
procedure myProc(myCsr out csr);
end;

create or replace package body mypkg as
procedure myProc(myCsr out csr) is
begin
open myCsr for
select * from scott.emp;
end myProc;
end;

Execute From the Editor.
In the Editor for the Package Body I place the cursor in the Proc that I want to
run and click the Set Parameter Icon, the icon that looks like "(...)". On that
window click the "Options" button and you will see a REF CURSOR section. Select
the last radio button "Load into Grid...." click OK and OK again. Now click the
Lightening Bolt. After termination you should see your results in a grid on the
REF CURSOR tab at the bottom of the editor.

Execute from the Schema Browser.
Select the proc you want to run and click the lightening bolt. Do the same
thing on the Set Parameter window as above. After execution the results should
be displayed in the REF CURSOR grid.

Ed
[TeamT]





-----Original Message-----
From: ***@yahoogroups.com [mailto:***@yahoogroups.com] On Behalf Of solmyr72
Sent: Thursday, December 28, 2006 5:53 AM
To: ***@yahoogroups.com
Subject: [toad] Calling a stored procedure that returns a cursor


Hi,

I'm new to Toad.
I have a stored procedure which returns a 'ref cursor' as an 'out'
parameter.
Is it possible to call such a procedure from TOAD, and make TOAD show the
table data which is represented by this cursor ?

For example, suppose my procedure is:

TYPE rf_cursor IS REF CURSOR;
procedure myProcedure(crs OUT ref_cursor) IS
BEGIN
open rf_cursor for
select * from PRODUCTS;
END

For this example, i'd like to invoke this procedure from TOAD, and see my
entire PRODUCTS table (because that's what my cursor points to).


Thanks very much !
--
View this message in context:
http://www.nabble.com/Calling-a-stored-procedure-that-returns-a-cursor-tf2889770
.html#a8073225
Sent from the Oracle TOAD mailing list archive at Nabble.com.



Questions? Try the on-line FAQ:
http://asktoad.com/DWiki/doku.php?id=faq:questions

Do you know about the other TOAD Yahoo Message Boards? Go here to find out more
- http://www.toadsoft.com/maillist.htm
Yahoo! Groups Links




**************************************************************************
Notice of Confidentiality: This e-mail communication and the attachments hereto, if any, are intended solely
for the information and use of the addressee(s) identified above and may contain information which is legally
privileged and/or otherwise confidential. If a recipient of this e-mail communication is not an addressee (or an
authorized representative of an addressee), such recipient is hereby advised that any review, disclosure,
reproduction, re-transmission or other dissemination or use of this e-mail communication (or any information
contained herein) is strictly prohibited. If you are not an addressee and have received this e-mail communication
in error, please advise the sender of that circumstance either by reply e-mail or by telephone at (407) 384-8818
immediately delete this e-mail communication from any computer and destroy all physical copies of same.

Replies Filtered: Any incoming e-mail reply to this communication will be electronically filtered for "spam"
and/or "viruses." That filtering process may result in such reply being quarantined (i.e., potentially not received
at our site at all) and/or delayed in reaching us. For that reason, we cannot guarantee that we will receive your
reply and/or that we will receive it in a timely manner. Accordingly, you should consider sending communications
to us which are particularly important or time-sensitive by means other than e-mail.
**************************************************************************
aversack
2007-01-02 14:31:30 UTC
Permalink
Hi Solmyr72,

At my company we have just converted a few hundred Sybase stored
procedures and functions to Oracle procedures using reference cursors.
Below is a sample script showing a typical procedure using one input
parameter and a reference cursor (:c1) as an output parameter. Make
sure that you execute the procedure as a script by hitting F5 or
selecting on the main menu > Editor > "Execute as a script". I did
have some occasional problems in an earlier version of TOAD where this
hung TOAD up and I had to close and re-open another instance of TOAD.
If that happens to you you can also shell out to SQL*Plus by clicking
on the "Execute SQL via SQL*Plus" (make sure TOAD is pointing to the
SQL*Plus executable file).

The SQL*Plus output is not as pretty but you should get results if the
previous technique doesn't work.

Sample ref Cursor procedural script:

VARIABLE c1 REFCURSOR;

BEGIN
getAnonTest ('00133850-BLD', :c1 );
END;
/
PRINT c1


Have fun,

Larry hardebeck
Post by solmyr72
Hi,
I'm new to Toad.
I have a stored procedure which returns a 'ref cursor' as an 'out'
parameter.
Is it possible to call such a procedure from TOAD, and make TOAD show the
table data which is represented by this cursor ?
TYPE rf_cursor IS REF CURSOR;
procedure myProcedure(crs OUT ref_cursor) IS
BEGIN
open rf_cursor for
select * from PRODUCTS;
END
For this example, i'd like to invoke this procedure from TOAD, and see my
entire PRODUCTS table (because that's what my cursor points to).
Thanks very much !
--
http://www.nabble.com/Calling-a-stored-procedure-that-returns-a-cursor-tf2889770.html#a8073225
Post by solmyr72
Sent from the Oracle TOAD mailing list archive at Nabble.com.
Questions? Try the on-line FAQ: http://asktoad.com/DWiki/doku.php?id=faq:questions

Do you know about the other TOAD Yahoo Message Boards? Go here to find out more - http://www.toadsoft.com/maillist.htm
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/toad/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/toad/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:toad-***@yahoogroups.com
mailto:toad-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
toad-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

Loading...