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 5846187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:32:29+00:00 2026-05-22T12:32:29+00:00

I have kind of a tricky Oracle problem. I am trying to select one

  • 0

I have kind of a tricky Oracle problem. I am trying to select one set of data, we’ll call items. For each item I want to call another procedure and return an Inventory Item. I have two operations I am not sure on how to perform.

  1. How do I retrieve a value from the nested procedure?

  2. How do I return those retrieved values in the form of SYS_REFCURSOR?

My attempt here was to put the results from spSelect_Inv_Search into a nested table called ITEMS_TABLE. This is not working.

Code below

PROCEDURE SPSELECT_ITEM (IO_CURSOR OUT SYS_REFCURSOR) 
AS   
  MY_CURSOR SYS_REFCURSOR;
  TYPE ITEM_TYPE IS TABLE OF ITEMS.ITEM_NO%TYPE;
  ITEM_TABLE ITEM_TYPE := ITEM_TYPE();

  CURSOR ITEMS_CURSOR IS
      SELECT ITEM_NO 
      FROM ITEMS;

  V_COUNTER INTEGER := 0;
BEGIN
  FOR ITEM_REC IN ITEM_CURSOR LOOP
    V_COUNTER := V_COUNTER + 1;
    ITEM_TABLE.EXTEND;
    ITEM_TABLE(V_COUNTER) := spSelect_Inv_Search(ITEM_REC.ITEM_NO, MY_CURSOR);
  END LOOP;
END SPSELECT_ITEMS;

Any help is appreciated, thanks.

  • 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-05-22T12:32:30+00:00Added an answer on May 22, 2026 at 12:32 pm

    You seem to be wanting to merge an unknown number of SYS_REFCURSOR result sets into one big one. If you know the structure of the cursor returned from spSelect_Inv_Search you can do this with an intermediate pipelined function.

    create package p as
        type tmp_rec_type is record (owner all_objects.owner%type,
            object_type all_objects.object_type%type,
            objects number);
        type tmp_rec_table is table of tmp_rec_type;
    
        procedure proc1(p_owner in varchar2, p_cursor out sys_refcursor);
        function func2 return tmp_rec_table pipelined;
        procedure proc3(p_cursor out sys_refcursor);
    end;
    /
    

    The types can be defined here, they don’t have to be at SQL level as you won’t ever need to reference them outside the package.

    create package body p as
        procedure proc1(p_owner in varchar2, p_cursor out sys_refcursor) as
        begin
            open p_cursor for select owner, object_type, count(*)
                from all_objects
                where owner = p_owner
                group by owner, object_type;
        end;
    
        function func2 return tmp_rec_table pipelined as
            cursor c1 is select distinct owner
                from all_tables where owner in ('SYS','SYSTEM');
            tmp_cursor sys_refcursor;
            tmp_rec tmp_rec_type;
        begin
            for r1 in c1 loop
                proc1(r1.owner, tmp_cursor);
                loop
                    fetch tmp_cursor into tmp_rec;
                    exit when tmp_cursor%notfound;
                    pipe row(tmp_rec);
                end loop;
            end loop;
        end;
    
        procedure proc3(p_cursor out sys_refcursor) as
        begin
            open p_cursor for select * from table(func2);
        end;
    end p;
    /
    

    Then to execute, which you can do outside the package despite the types used for the intermediate stage, you can do this to test in SQL*Plus or SQL Developer:

    var rc refcursor;
    exec p.proc3(:rc);
    print rc;
    

    For my database this gives:

    OWNER                          OBJECT_TYPE         OBJECTS                
    ------------------------------ ------------------- ---------------------- 
    SYSTEM                         VIEW                1                      
    SYSTEM                         TABLE               5                      
    SYS                            VIEW                1056                   
    SYS                            CONSUMER GROUP      2                      
    SYS                            PROCEDURE           11                     
    SYS                            FUNCTION            56                     
    SYS                            SEQUENCE            1                      
    SYS                            OPERATOR            6                      
    SYS                            EVALUATION CONTEXT  1                      
    SYS                            TABLE               13                     
    SYS                            WINDOW GROUP        1                      
    SYS                            PACKAGE             162                    
    SYS                            WINDOW              2                      
    SYS                            TYPE                529                    
    SYS                            JOB CLASS           1                      
    SYS                            SCHEDULE            1     
    

    This is obviously very contrived as you’d do this as a single query, but I’m assuming your inner procedure needs to do something more complicated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some kind of problem with jQuery selectors. Let's say i want to
I have kind of a tricky problem I'm working on in my current rails
How would you tackle this problem: I have data in my data store. Each
I have a kind of tricky layout in my app, so the main problem
I have a kind of basic (but still unresolved) problem. I'm building a program
Ok this is a tricky one. It might not be possible. test<-data.frame(var.a=c(1,1,1,1,2,2,2,3,3,3,3,3,4,4,5,5,5,5), var.b=c(1,2,1,3,2,3,4,3,2,2,1,2,1,2,3,4,1,2)) is
I'm facing kind of a tricky challenge here, maybe one of you could help
It's kind of tricky question, It's hard for me to expain what I want
this is kind of tricky: I have an C# web application running always on
Got kind of a tricky problem. I'm working on a project where we need

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.