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.
I have two stored procs, p_proc1 and p_proc2 . p_proc1 returns a refcursor and
Share
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