Oracle 使用ref游标中的记录,但未获得所需的o/p

Oracle 使用ref游标中的记录,但未获得所需的o/p,oracle,plsql,Oracle,Plsql,我试图在ref cursor中使用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; rc

我试图在ref cursor中使用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;
请帮助我改进代码,我可以使用object获得所需的输出,但我需要它
通过ref cursor。

请格式化您的代码,使其可读,并提供输入和预期输出的示例。我使用带有返回类型记录的ref cursor和返回类型为cursor的函数,我需要获取员工姓氏,o/pBe中的部门名称确保
select
语句打开光标,返回数据,并且SQL*PLUS
serveroutput
处于打开状态(
将serveroutput设置为打开状态)。它处于打开状态serveroutput处于打开状态