Go Back  IT Forums > Software > Oracle
User Name
Password
Reply
 
Thread Tools Search this Thread Display Modes

Oracle TOAD: Dislaying Ref Cursor in DataGrid?
  #1
Old 09-18-2006, 10:32 AM
Mario
Junior Member


Mario is offline
Mario's Info
Join Date: Sep 2006
Posts: 2
Default Oracle TOAD: Dislaying Ref Cursor in DataGrid?

I've spent far too long trying to discover the answer to this very
simple question. How do I use TOAD to display the result set from a
stored procedure? In Microsoft SQL Server, this is effortless. You
don't have to jump through any hoops or do anything funny! In TOAD for
Oracle I've seen many people ask this question, but I haven't found a
satisfactory answer. I even saw someone mention TOAD already having
the built-in functionality to display ref cursors, but I can't seem to
find the feature setting.

Why is something so simple as executing a stored procedure that returns
a result set (and viewing that result set) so cryptic?!

How do you do it?

I have TOAD 8.6.1.0 for Oracle.

My stored proc follows this pattern:

CREATE OR REPLACE PROCEDURE sp_get_recs (
i_parm1 IN NUMBER,
o_rs OUT types.resultset -- defined in a common package as a "ref
cursor"
)
AS

BEGIN

OPEN o_rs FOR SELECT * FROM MYTABLE WHERE PARM1 = i_parm1;

END sp_get_recs;
/

Reply With Quote
Oracle TOAD: Dislaying Ref Cursor in DataGrid?
  #2
Old 09-18-2006, 12:41 PM
Vladimir M. Zakharychev
Junior Member


Vladimir M. Zakharychev is offline
Vladimir M. Zakharychev's Info
Join Date: May 2006
Posts: 11
Default Oracle TOAD: Dislaying Ref Cursor in DataGrid?

Mario wrote:
Quote:
I've spent far too long trying to discover the answer to this very simple question. How do I use TOAD to display the result set from a stored procedure? In Microsoft SQL Server, this is effortless. You don't have to jump through any hoops or do anything funny! In TOAD for Oracle I've seen many people ask this question, but I haven't found a satisfactory answer. I even saw someone mention TOAD already having the built-in functionality to display ref cursors, but I can't seem to find the feature setting. Why is something so simple as executing a stored procedure that returns a result set (and viewing that result set) so cryptic?! How do you do it? I have TOAD 8.6.1.0 for Oracle. My stored proc follows this pattern: CREATE OR REPLACE PROCEDURE sp_get_recs ( i_parm1 IN NUMBER, o_rs OUT types.resultset -- defined in a common package as a "ref cursor" ) AS BEGIN OPEN o_rs FOR SELECT * FROM MYTABLE WHERE PARM1 = i_parm1; END sp_get_recs; /


T.O.A.D. is a 3rd-party tool, neither supported nor endorsed by Oracle,
so I think you should send your question and associated rant to its
developers (Quest Software) or tech support staff and see what they
have to say. Maybe this is a missing feature that they can add. In
SQL*Plus, which is Oracle-supplied tool, you would do it like this:

VAR x REFCURSOR
EXEC sp_get_recs(1, :x);
PRINT x

And please don't compare Oracle to MSSQL - they are completely
different in architecture, features, programming environments and what
not. I can name a ton of things I can effortlessly do in Oracle but
can't in MSSQL. This won't cause me to say that MSSQL sucks - it's just
different.

Regards,
Vladimir M. Zakharychev
N-Networks, makers of Dynamic PSP(tm)
http://www.dynamicpsp.com

Reply With Quote
Oracle TOAD: Dislaying Ref Cursor in DataGrid?
  #3
Old 09-18-2006, 01:42 PM
Mario
Junior Member


Mario is offline
Mario's Info
Join Date: Sep 2006
Posts: 2
Default Oracle TOAD: Dislaying Ref Cursor in DataGrid?

Thanks for your reply!

Reply With Quote
Oracle TOAD: Dislaying Ref Cursor in DataGrid?
  #4
Old 09-19-2006, 12:43 AM
sybrandb
Junior Member


sybrandb is offline
sybrandb's Info
Join Date: Jul 2006
Posts: 5
Default Oracle TOAD: Dislaying Ref Cursor in DataGrid?


Mario wrote:
Quote:
I've spent far too long trying to discover the answer to this very simple question. How do I use TOAD to display the result set from a stored procedure? In Microsoft SQL Server, this is effortless. You don't have to jump through any hoops or do anything funny! In TOAD for Oracle I've seen many people ask this question, but I haven't found a satisfactory answer. I even saw someone mention TOAD already having the built-in functionality to display ref cursors, but I can't seem to find the feature setting. Why is something so simple as executing a stored procedure that returns a result set (and viewing that result set) so cryptic?! How do you do it? I have TOAD 8.6.1.0 for Oracle. My stored proc follows this pattern: CREATE OR REPLACE PROCEDURE sp_get_recs ( i_parm1 IN NUMBER, o_rs OUT types.resultset -- defined in a common package as a "ref cursor" ) AS BEGIN OPEN o_rs FOR SELECT * FROM MYTABLE WHERE PARM1 = i_parm1; END sp_get_recs; /

From the TOAD 8.5.x help file


REF CURSOR Results Window
Note: This extended Toad feature is only available in Toad for Oracle
editions that include debugging functionality.

You can specify to have REF CURSOR results output to a separate window.
This window is dockable to the other debugger windows.

When a debug session terminates, this window displays each table that
was created for REF CURSORS for the Create and write to table option
described in Setting Parameters. Each table is shown in a grid on a
separate tab in the window.

Note: The REF CURSOR window has the following limitations:

Works only with strongly-typed REF CURSORs

Works only when the REF CURSOR type is declared in a package belonging
to the currently logged-in user

The three toolbar buttons are:

Refresh - refreshes the grid in the current tab (re-executes the select
* statement)

Close Tab - closes the current tab

Drop Table - drops the current table and closes the tab

The grid supports all the usual popup editors, but it is a read-only
query.


--
Sybrand Bakker
Senior Oracle DBA

Reply With Quote
Oracle TOAD: Dislaying Ref Cursor in DataGrid?
  #5
Old 09-26-2006, 06:30 PM
skippydigits
Junior Member


skippydigits is offline
skippydigits's Info
Join Date: Sep 2006
Posts: 2
Default Oracle TOAD: Dislaying Ref Cursor in DataGrid?


Mario wrote:
Quote:
I've spent far too long trying to discover the answer to this very simple question. How do I use TOAD to display the result set from a stored procedure? In Microsoft SQL Server, this is effortless. You don't have to jump through any hoops or do anything funny! In TOAD for Oracle I've seen many people ask this question, but I haven't found a satisfactory answer. I even saw someone mention TOAD already having the built-in functionality to display ref cursors, but I can't seem to find the feature setting. Why is something so simple as executing a stored procedure that returns a result set (and viewing that result set) so cryptic?! How do you do it? I have TOAD 8.6.1.0 for Oracle. My stored proc follows this pattern: CREATE OR REPLACE PROCEDURE sp_get_recs ( i_parm1 IN NUMBER, o_rs OUT types.resultset -- defined in a common package as a "ref cursor" ) AS BEGIN OPEN o_rs FOR SELECT * FROM MYTABLE WHERE PARM1 = i_parm1; END sp_get_recs; /


I usually create a block that calls the procedure and keep it around
for unit testing later on. Note the little :colon before the cursor
variable. This is what lets you see the results in Toad. A little pop
up appears and asks you what :cur is. Tell it you really mean cursor.

DECLARE

type x is ref cursor;

cur x;

BEGIN

sp_get_recs(1,:x);

END;

Reply With Quote
Oracle TOAD: Dislaying Ref Cursor in DataGrid?
  #6
Old 09-26-2006, 06:31 PM
skippydigits
Junior Member


skippydigits is offline
skippydigits's Info
Join Date: Sep 2006
Posts: 2
Default Oracle TOAD: Dislaying Ref Cursor in DataGrid?

Don't need the fancy edition of Toad to do it that way.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Style Design by vBStyles.com


Top Contact Us - IT Forums - Archive - MyLounge Top
MyLounge.com Site Map
Forum: Cars, Cell Phone, Database, Games, Home Improvement, IT, Music, School, Sports, Web Design, Web Server, Weight Loss

The MyLounge.com forum is intended for informational use only and should not be relied upon and is not a substitute for any advice. The information contained on MyLounge.com are opinions and suggestions of members and is not a representation of the opinions of MyLounge.com. MyLounge.com does not warrant or vouch for the accuracy, completeness or usefulness of any postings or the qualifications of any person responding. Please consult a expert or seek the services of an attorney in your area for more accuracy on your specific situation. Please note that our forums also serve as mirrors to Usenet newsgroups. Many posts you see on our forums are made by newsgroup users who may not be members of MyLounge.com Term of Service