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!

Inserting Values Returned By An Implicit Cursor Returning Procedure

Ray WinkelmanAug 17 2016 — edited Aug 18 2016

Hey All,

Back again, with yet another pretty specific thing I'd like to learn how to do. I'm currently writing a procedure that manipulates data stored in a temporary table.

There's a procedure owned by my current user, that returns a cursor pointing to the exact row set I'd like to initially seed the temporary table with, before doing some operations on said table.

Now, I know the cursor being returned is not to be used like a row set, and that the cursor is not a moving part as well; which leads me to ask: What's required to get the data I want in the table?

The procedure is called by an application, so turning it into a function is not an option.

Here's an example of an implicit returning procedure:

create or replace procedure procedurename(p_var in number)

as

  refcursor sys_refcursor;

begin

    open refcursor for

      select p_var

      from   dual;

    dbms_sql.return_result(refcursor);

end;

/

Now, here's the general idea of what I'd like to do in PL-SQL (This one-liner actually works in SQL Server):

begin

  insert into tablename procedurename(1);

end;

/

Obviously there's cursor related coding that needs to be done, but what's the best way to do this without bogging down the engine?

Answers are always appreciated, however explanations of answers are the best type of contribution to our community.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 16 2016
Added on Aug 17 2016
20 comments
3,475 views