I have an SP which will return a REF CURSOR containing a certain block of data:
PROCEDURE MAIN_SP(PARAM1 IN NUMBER,
PARAM2 IN VARCHAR2,
..
P_REF_CURSOR OUT REF CURSOR)
BEGIN
..
OPEN P_REF_CURSOR FOR
SELECT V_SUCCESSFUL_COUNT, V_RESPONSE_CODE FROM DUAL;
END
Then there is an outer SP which will call this main one in a loop. The SP signature matches the inner one’s with the exception that it takes an array of values, one of which gets substituted in a loop as one of the Main’s params. In this example, it’s PARAM2 in the Main SP.
PROCEDURE OUTER_SP(PARAM1 IN NUMBER,
P_REF_ID_LIST IN TABLE OF VARCHAR2,
..,
P_REF_CURSOR OUT REF CURSOR)
BEGIN
..
FOR i IN 1 .. P_REF_ID_LIST.COUNT LOOP
MAIN_SP(PARAM1, P_REF_ID_LIST(i), .., P_REF_CURSOR);
END
END
If this gets executed N times, am I correct that I only get the single last REF CURSOR block back? There’s a V_RESPONSE_CODE
included in each REF CURSOR output, which might contain an error. How would I collect and examine all the results to see if at least one has a V_RESPONSE_CODE > 0
, for example, indicating an error? The outer SP’s REF CURSOR should be either a concatenated list or array of all the individual REF CURSORs.