Hi All,
I have a procedure that returns a SYS_REFCURSOR out of a general select that is not based on a specific table where I can generate a type using %Type.
I want to return both the result cursor and also an aggregation (example number of rows in the below procedure). However I fail to generate an array of SYS_REFCURSOR to use it in the FETCH before looping.
I need help to know what I am missing and/or dont know in order to avoid repeating the select again to get the aggregate result.
CREATE OR REPLACE PROCEDURE P_GET_DATA_TEST
(
I_NUM IN NUMBER,
CUR_REF OUT SYS_REFCURSOR,
I_TOTAL_ROWS OUT NUMBER
)
AS
TYPE ARY_ARRAY IS TABLE OF SYS_REFCURSOR;
AR_MY_ARRAY ARY_ARRAY;
BEGIN
OPEN CUR_REF FOR
SELECT ROWNUM
FROM ALL_OBJECTS
WHERE ROWNUM <= i_num ;
I_total_rows:=0;
FETCH CUR_REF BULK COLLECT INTO ar_My_Array;
FOR I IN 1..ar_My_Array.COUNT LOOP
I_total_rows := I_total_rows + 1;
END LOOP;
/*
I want to avoid:
OPEN CUR_REF FOR
SELECT count(ROWNUM ) into I_total_rows
FROM ALL_OBJECTS
WHERE ROWNUM <= i_num ;
*/
CLOSE CUR_REF;
END;