我正在尝试执行返回sys_refcursor作为输出的过程。该过程是PROCEDURE GET_EMPLOYEEs(P_ID in NUMBER, P_OUT_CURSOR OUT SYS_REFCURSOR);
我在SQL Developer 1.5中编写了以下匿名块,并且执行良好,但当我尝试打印游标时,出现错误。该游标返回emp_name、salary和其他列。
set serveroutput on;
declare
result sys_refcursor;
begin
emp.emp360_utils.GET_EMPLOYEEs(222334,result);
dbms_output.put_line(result); // Error here
end;
错误是:
PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
更新:为游标进行了迭代,但仍然出现“对变量dummycursor的无效引用”错误。
set serveroutput on;
declare
dummycursor sys_refcursor;
result sys_refcursor;
begin
emp.emp360_utils.GET_EMPLOYEEs(222334,result);
LOOP
fetch result into dummycursor;
EXIT when result%notfound;
dbms_output.putline(dummycursor.lsn);
end loop;
end;