Practica 5
Practica 5
varchar(14); empleados number; promedio decimal(8,2); apell varchar(14); ubicacion NUMBER(4,0); nom_ciudad VARCHAR2(30); pais_cod char(2); pais_nom VARCHAR2(40); cont number; begin select count(*) into cont from employees where employee_id = cod_emp; if cont = 0 then dbms_output.put_line('No existe el codigo del empleado'); return; end if; nro_emp := 200; select first_name into nomb from employees where employee_id = nro_emp; dbms_output.put_line( nro_emp ' - ' nomb ' - ' apell ); select department_id into cod_depa from employees where employee_id= cod_emp ; select count(*), avg(salary) into empleados,promedio from employees where DE PARTMENT_ID= cod_depa ; SELECT location_id into ubicacion from departments where department_id=cod_d epa; SELECT city,COUNTRY_ID into nom_ciudad,pais_cod from locations where locatio n_id= ubicacion; SELECT country_name into pais_nom from countries where country_id= pais_cod; DBMS_OUTPUT.PUT_LINE('Cantidad de empleados del departamento: ' empleado s); DBMS_OUTPUT.PUT_LINE('Salario promedio del departamento: ' promedio); DBMS_OUTPUT.PUT_LINE('Ciudad: ' nom_ciudad ); DBMS_OUTPUT.PUT_LINE('Pais: ' pais_nom); end;
-- PROBELMA 2 SET SERVEROUTPUT ON CREATE OR REPLACE PROCEDURE ver_departamento(cod in number) IS nom_depa varchar(30); emp_cant number; plan_total number(8,2); sueld_prom decimal(8,2); sueld_min number(8,2); sueld_max number(8,2); jefe_cod NUMBER(6,0); nombreJ VARCHAR2(10); apellidoJ VARCHAR2(10); ubicacion NUMBER(4,0); nom_ciudad VARCHAR2(30); pais_cod char(2); pais_nom VARCHAR2(40); cont number; BEGIN select count(*) into cont from departments where department_id = cod; if cont = 0 then dbms_output.put_line('No existe el departamento'); return; end if; select department_name,manager_id into nom_depa,jefe_cod from departments whe re department_id=cod; select count(*), avg(salary), max(salary), min(salary), sum(salary) into emp_ cant, sueld_prom, sueld_max, sueld_min, plan_total from employees where DEPARTME NT_ID=cod; select first_name, last_name into nombreJ, apellidoJ from EMPLOYEES where EMP LOYEE_ID=jefe_cod; SELECT location_id into ubicacion from departments where department_id=cod; SELECT city,COUNTRY_ID into nom_ciudad,pais_cod from locations where location _id= ubicacion; SELECT country_name into pais_nom from countries where country_id= pais_cod; DBMS_OUTPUT.PUT_LINE('Nombredel departamento: ' nom_depa); DBMS_OUTPUT.PUT_LINE('Cantidad de empleados en este departamento: ' em p_cant); DBMS_OUTPUT.PUT_LINE('Importe de la plan_total en este departamento: ' plan_total ); DBMS_OUTPUT.PUT_LINE('Salario menor por departamento: ' sueld_min); DBMS_OUTPUT.PUT_LINE('Salario mayor por departamento: ' sueld_max); DBMS_OUTPUT.PUT_LINE('Salario promedio del departamento: ' sueld_prom) ; DBMS_OUTPUT.PUT_LINE('Nombre ciudad: ' nom_ciudad ); DBMS_OUTPUT.PUT_LINE('Pais nombre: ' pais_nom); DBMS_OUTPUT.PUT_LINE('Nombre Del Jefe: ' nombreJ ' ' apellidoJ) ; END;