Reputation: 803
I have a procedure which returns a SYS_REFCURSOR
as an OUT
parameter. What I would like to do is call that procedure, and use that returned SYS_REFCURSOR
in another procedure. In this second procedure, I would need to run a GROUP BY
on the results, and return it in another SYS_REFCURSOR
.
The problem I'm encountering is that I do not know the name or number of columns in advance.
Does anyone have any ideas for a solution? Thank you in advance.
Upvotes: 2
Views: 1107
Reputation: 149
Actually, you can do this, but it requires some effort and for most cases it's just overkill.
The way is the next sequence of steps:
simple example, to illustrate the idea:
select EMPNO, count(*) from
xmltable(
‘/ROWSET/ROW’
PASSING xmltype(CURSOR( SELECT E.EMPNO, E.ENAME, D.DNAME, D.DEPTNO FROM SCOTT.EMP E, SCOTT.DEPT D WHERE e.deptno=D.DEPTNO ))
columns
EMPNO PATH ‘EMPNO’,
ENAME PATH ‘ENAME’,
DNAME PATH ‘DNAME’ ,
DEPTNO PATH ‘DEPTNO’
)
group by EMPNO
Upvotes: 3