Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to call a procedure with SYS_REFCURSOR OUT parameter

Rob JonesDec 23 2013 — edited Dec 24 2013

Hi,

Using Oracle 11g R2.

I'd like to know if it is possible to display the results of a SYS_REFCURSOR in a query. For example, if I had the following stored procedure

create or replace procedure testprocedure (result OUT sys_refcursor)

as

begin

   open result for

      select 1 from dual

      union all

      select 2 from dual;

end;

I'd like to call this procedure similar to the way a query is called and executed. Like this

select * from testprocedure

I've seen plenty of examples on the web which show how it is possible to loop through results of a sys_refcursor inside of an anonymous block and display the results using dbms_output.putline, but this isn't the method I am looking for.

This post has been answered by BluShadow on Dec 24 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 21 2014
Added on Dec 23 2013
7 comments
39,794 views