Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7766369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:23:55+00:00 2026-06-01T15:23:55+00:00

I have a stored proc with the basic layout below that returns a sys_refcursor

  • 0

I have a stored proc with the basic layout below that returns a sys_refcursor as a result set. (Technically it reurns four but for the sake of clarity I just say one). The result set is a selection from a temp table.

procedure aProcedure
( C1 in out sys_refcursor
) is
begin
--populate Temp_Table here with a stored proc call;
OPEN C1 FOR
SELECT Cols
FROM TEMP_TABLE;

I need to insert this result set from C1 into a permanent table using a different stored procedure. Is this Do-able or do I need to re-build the result set all over again?

I’ve been able to find information on working with cursors and result sets outside of oracle but not for working with them within itself.

I know it might make sense to just do the insert from the first stored proc but that’s not really how I need it to happen. It’s an optional requirement to save the result set permanently.

Thanks for any helpful info.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:23:56+00:00Added an answer on June 1, 2026 at 3:23 pm

    Assuming that the caller knows the structure of the cursor that aProcedure is opening, you can do something like this.

    declare
      l_rc sys_refcursor;
      l_rec temp_table%rowtype;
    begin
      aProcedure( l_rc );
      loop
        fetch l_rc
         into l_rec;
        exit when l_rc%notfound;
    
        dbms_output.put_line( l_rec.col1 );
      end loop;
      close l_rc;
    end;
    /
    

    If you can’t fetch into a record type, you can also fetch into a number of other scalar local variables (the number and type have to match the number and type of columns that aProcedure specifies in its SELECT list). In my case, I defined aProcedure to return two numeric columns

    declare
      l_rc sys_refcursor;
      l_col1 number;
      l_col2 number;
    begin
      aProcedure( l_rc );
      loop
        fetch l_rc
         into l_col1, l_col2;
        exit when l_rc%notfound;
        dbms_output.put_line( l_col1 );
      end loop;
      close l_rc;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored proc which returns a result set with somewhere around 20
I have a stored proc that returns a resultset thus: testID(guid), testName, outcomeID(guid), outcomeName
I have a stored proc on sql server 2008 that excepts a int parameter.
I have a Stored proc which returns 6 select statement results. I'm trying to
I have a stored proc which unions some data and returns back. At max
I have a VB.Net function which executes a Oracle Stored Proc and returns a
I have a WCF service method that calls a SQL stored proc. I'm developing
I have a stored proc that produces a table like this: PeriodStart PeriodEnd TotalActive
I have a stored proc that searches for products (250,000 rows) using a full
I have a stored proc (SS2008) that takes a couple int ids and needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.