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

  • Home
  • SEARCH
  • 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 3222554
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:00:16+00:00 2026-05-17T16:00:16+00:00

I have two stored procs, p_proc1 and p_proc2 . p_proc1 returns a refcursor and

  • 0

I have two stored procs, p_proc1 and p_proc2. p_proc1 returns a refcursor and I want to use the data in p_proc2. Is it possible call p_proc1 in p_proc2 and modify the dataset (outer join another table)? The database is Oracle.

  • 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-17T16:00:17+00:00Added an answer on May 17, 2026 at 4:00 pm

    Not directly, no.

    A SYS_REFCURSOR is a pointer to a result– the only thing you can do with that is to fetch the data. You can’t modify the result set.

    P_PROC2 could fetch the data from the SYS_REFCURSOR, issue queries to get additional data from some other table, and return something to the caller. At that point, I would tend to favor turning P_PROC2 into a pipelined table function. But you could just return a collection with the modified data in it.

    If p_proc2 absolutely needs to return a REF CURSOR, you could fetch the data from p_proc1’s REF CURSOR into a global temporary table and then open a new cursor in p_proc2 that queries this global temporary table and does whatever additional manipulation you wish. Something like

    SQL> create global temporary table tmp_emp
      2  as
      3  select empno, ename, deptno from emp where 1=2;
    
    Table created.
    
    
    SQL> create or replace procedure p1( p_cur1 out sys_refcursor )
      2  as
      3  begin
      4    open p_cur1 for select * from emp;
      5  end;
      6  /
    
    Procedure created.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  create or replace procedure p2( p_cur2 out sys_refcursor )
      2  as
      3    l_cur1 sys_refcursor;
      4    l_rec  emp%rowtype;
      5  begin
      6    p1( l_cur1 );
      7    loop
      8      fetch l_cur1 into l_rec;
      9      exit when l_cur1%notfound;
     10      insert into tmp_emp( empno, ename, deptno ) values( l_rec.empno, l_rec
    ename, l_rec.deptno );
     11    end loop;
     12    open p_cur2 for
     13      select empno, ename, dname
     14        from tmp_emp,
     15             dept
     16       where dept.deptno = tmp_emp.deptno;
     17* end;
    SQL> /
    
    Procedure created.
    
    SQL> variable rc refcursor;
    SQL> exec p2( :rc );
    
    PL/SQL procedure successfully completed.
    
    SQL> print rc
    
         EMPNO ENAME      DNAME
    ---------- ---------- --------------
          7839 KING       ACCOUNTING
          7934 MILLER     ACCOUNTING
          7782 CLARK      ACCOUNTING
          7369 smith      RESEARCH
          7902 FORD       RESEARCH
          7876 ADAMS      RESEARCH
          7788 SCOTT      RESEARCH
          7566 JONES      RESEARCH
          7900 JAMES      SALES
          7499 ALLEN      SALES
          7698 BLAKE      SALES
    
         EMPNO ENAME      DNAME
    ---------- ---------- --------------
          7654 MARTIN     SALES
          7844 TURNER     SALES
          7521 WARD       SALES
    
    14 rows selected.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two stored procedures I wish to use in my stored procedure, but
I have a stored procedure that takes no parameters, and it returns two fields.
I have two stored procedures. One (test_proc_outside) makes a call to a second one
I have a SQL Server 2005 stored proc which returns two result sets which
I have two stored procedures that I want execute wrapped in a transaction. For
This is two part question: I have two stored procedures: sp1 & sp2. If
I have two PL/SQL Stored procedure each handling its own Transaction (Begin/Commit and Rollback
I have two tables which have some transactional stuff stored in them. There will
I'm using devexpress and i have two problems. My insert stored procedure work fine.
I have a an object stored in the model called domain, which has two

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.