Printing Oracle Sys_refcursor in Oracle SQL Developer 1.5
You would need to loop over the ref cursor and for each row in it, print out the individual fields. In your updated version you need to fetch the cursor into local scalar variables, not another ref cursor:
set serveroutput on;declare result sys_refcursor; lsn number; -- guessing the data typebegin emp.emp360_utils.GET_EMPLOYEEs(222334,result); loop fetch result into lsn; -- and other columns if needed exit when result%notfound; dbms_output.put_line(lsn); end loop;end;/
I've guessed lsn
is a number, if not then declare that as the right type. If the cursor returns more than one column then you will need to declare local variables for each of them and fetch them all into those, even if you're only displaying one of them.
If you just want to display it then you can use a bind variable to do this instead (checked in the current version and back to 1.5.0):
variable result refcursorbegin emp.emp360_utils.GET_EMPLOYEEs(222334, :result); end;/print result
Note that the variable
command is not in the declare
block; it is a SQL Developer command, not a PL/SQL command. As is print
, though both are only documented in the SQL*Plus docs. And also note the colon at the start of :result
within the block, which indicates that it is a bind variable, not a local PL/SQL variable.