Você está na página 1de 1

DECLARE

CURSOR c_nombres is
select DEPARTMENT_NAME,manager_id,location_id from DEPARTMENTS;
type t_reg_empleado is record(nom DEPARTMENTS.DEPARTMENT_NAME%TYPE ,man DEPARTME
NTS.MANAGER_ID%type,
loc DEPARTMENTS.LOCATION_ID%TYPE);
reg_empleado t_reg_empleado;
BEGIN
open c_nombres;
LOOP
FETCH c_nombres into reg_empleado;
EXIT when c_nombres%notfound;
dbms_output.put_line(reg_empleado.nom||' '||reg_empleado.man||' '||reg_empleado.
loc);
end loop;
close c_nombres;
END;
///
create or replace function fn_datos_emp (cod in number )return varchar is
cursor c_nombres is
select first_name, last_name,salary
from employees
where department_id=cod;
type t_reg_datos is record (
nom employees.first_name%type,
ap employees.last_name%type,
sal employees.salary%type
);
r_datos t_reg_datos;
BEGIN
open c_nombres;
loop
fetch c_nombres into r_datos;
exit when c_nombres%notfound;
--DBMS_OUTPUT.PUT_LINE('el nombre es :'||r_datos.nom);
return r_datos.sal;
end loop;
close c_nombres;
END;
select fn_datos_emp(50) from dual;

Você também pode gostar