sorry for the kind of broad title to the question, but I didn't find a way to simplify it further.
I'm creating a package for a client, this package has a procedure which returns a SYS_REFCURSOR
. The query that feeds it is a multi-table select with about 20 fields. On a second procedure I need to call this one, and loop through the results to feed other locations.
I'm having problems using the into
part of the loop. I can't use table%ROWTYPE
. I tried to declare an OBJECT
on the procedure but it was not allowed. Will I have to do a FETCH XXX INTO LIST_OF_INDVIDUAL_VARIABLES
?
DECLARE
dt_field TABLE1.dt_field%TYPE;
p_resultset SYS_REFCURSOR;
p_individual OBJECT (
FIELD0 DATE,
FIELD1 TABLE.FIELD1%TYPE,
FIELD2 TABLE.FIELD2%TYPE,
FIELD3 TABLE.FIELD3%TYPE,
FIELD4 TABLE.FIELD4%TYPE
);
BEGIN
PACKAGE.PROCEDURE1(dt_field);
dbms_output.put_line(dt_field);
PACKAGE.PROCEDURE2(dt_field, p_resultset);
LOOP
-- this do not work
FETCH p_resultset INTO p_individual;
EXIT WHEN p_resultset%NOTFOUND;
-- DO STUFF ON EACH RETURNED ROW
END LOOP;
CLOSE p_resultset;
END;