User Tools

Site Tools


kurs:emp_per_department_function
FUNCTION hr.emp_dep_list
  ( v_department_name IN departments.department_name%TYPE)
  RETURN emp_list IS

cursor c_emp(p_department_name varchar2) is 
SELECT DEPARTMENTS.DEPARTMENT_NAME, EMPLOYEES.LAST_NAME 
FROM DEPARTMENTS , EMPLOYEES 
WHERE ( (DEPARTMENTS.DEPARTMENT_ID = EMPLOYEES.DEPARTMENT_ID) AND
(DEPARTMENTS.DEPARTMENT_NAME = p_department_name) );

v_emp emp_list := emp_list();
-- v_emp_b emp_list := emp_list();

BEGIN 
  
  for r_emp in c_emp(v_department_name) loop 
    v_emp.extend;
    v_emp(v_emp.last) := r_emp.last_name; 
  end loop;
  
/*  open c_emp;
   fetch c_emp(p_department_name => v_department_name)
      bulk collect into v_emp_b;
  close c_emp; */
  return v_emp;

END;
kurs/emp_per_department_function.txt · Last modified: 2014/09/10 21:22 (external edit)