PL/SQL print out ref cursor returned by a stored procedure
Note: This code is untested
Define a record for your refCursor return type, call it rec. For example:
TYPE MyRec IS RECORD (col1 VARCHAR2(10), col2 VARCHAR2(20), ...); --define the recordrec MyRec; -- instantiate the record
Once you have the refcursor returned from your procedure, you can add the following code where your comments are now:
LOOP FETCH refCursor INTO rec; EXIT WHEN refCursor%NOTFOUND; dbms_output.put_line(rec.col1||','||rec.col2||','||...);END LOOP;
If you want to print all the columns in your select clause you can go with the autoprint command.
CREATE OR REPLACE PROCEDURE sps_detail_dtest(v_refcur OUT sys_refcursor)ASBEGIN OPEN v_refcur FOR 'select * from dummy_table';END;SET autoprint on;--calling the procedureVAR vcur refcursor;DECLARE BEGIN sps_detail_dtest(vrefcur=>:vcur);END;
Hope this gives you an alternate solution