我试图在ref光标中使用record作为返回类型,但是没有获得输出。
代码是:
declare
type rec is record (
last_name varchar2(20),
department_id number(10),
department_name varchar2(10)
);
type c1 is ref cursor return rec;
c2 c1;
rc2 c2%rowtype;
function get_data return c1 is
c3 c1;
begin
open c3 for
select e.last_name ,
e.department_id,
d.department_name
from employees e
join departments d
on e.department_id = d.department_id;
return c3;
end;
begin
c2 := get_data;
loop
fetch c2 into rc2;
exit when c2%notfound;
dbms_output.put_line(rc2.last_name);
end loop;
end;
请帮助我改进代码我可以使用对象获得所需的输出,但我需要它 通过ref cursor。