domingo, 27 de mayo de 2012

26 de Mayo Ejercicio 1 Solemne 2

-- ejercicio 1 solemne 2
set serveroutput on;
Declare
Cursor Ldepto is
select d.department_id, department_name, count(employee_id) as total
from employees e, departments d
where e.department_id = d.department_id
group by d.department_id, department_name
order by department_name;
msg char(1);
cnt integer := 0;
Begin
For reg in Ldepto Loop --el reg toma el department_id, department_name y el total, del cursor Ldepto
  if mod(reg.total,2) = 0 then
    msg := '*';
    cnt := cnt+1;
  else
    msg := '';
  End if;
  dbms_output.put_line(reg.department_id || ' ' || reg.department_name || ' ' || reg.total || ' ' || msg);
End Loop;
  dbms_output.put_line('El total de departamentos con cantidad de empleados PAR es: ' || cnt);
End;

No hay comentarios:

Publicar un comentario