Connect programmer/p@9i


create or replace package Employees_Cur_Ref_Cursor is
  type Last_Names_Tab_t is table of employees.last_name%type
    index by binary_integer;


  function Fetch_All_Rows ( p_department_id in employees.department_id%type )
    return Last_Names_Tab_t;
end Employees_Cur_Ref_Cursor;
/
Show Errors


create or replace package body Employees_Cur_Ref_Cursor is

  function Fetch_All_Rows ( p_department_id in employees.department_id%type )
     return Last_Names_Tab_t
  is
    v_last_names_tab Last_Names_Tab_t;
    c_employees sys_refcursor;

  begin
    open c_employees for
      select last_name from employees where department_id = p_department_id;

    fetch c_employees bulk collect into v_last_names_tab;

    -- Activate the next statement for more refined observations...
    /*

    Wait.Go;
    */

    close c_employees;
    return v_last_names_tab;
  end Fetch_All_Rows;

end Employees_Cur_Ref_Cursor;
/

Show Errors