jueves, 1 de septiembre de 2011

Datos de un Cursor

ceao duoc facebook

centrodealumnosao@gmail.com



declare

_________
_________
_________ variables
_________
_________ cursores

begin
_________
_________
_________
_________

exception
_________
_________
_________
_________
end;


select
from
where
having ( va asociado al group by)
group by
order by


select * from tab



select department_name as "departamento",count(*) as "total empleados"
from employees E,departments D
where E.department_id = D.department_id
having count (employee_id)> 3
group by department_name
order by department_name

desc departments

select * from employees


declare
cursor myCursor is
select department_id, count(*)as "total Empleados"
from employees
group by department_id
order by department_id;
vDepartamento employees.employee_id%type;
vTotalEmpleados integer;
begin
open myCursor;
loop
fetch myCursor into vDepartamento,vTotalEmpleados;
exit when myCursor%notfound;
dbms_output.put_line(vDepartamento || ' ' || vTotalEmpleados);
end loop;
close myCursor;
end

select department_name
from departments
where department_id = 10




declare
vNumDepto integer := 10;
vNomDepto varchar2(30);

begin
select department_name into vNomDepto
from departments
where department_id = vNumDepto;


dbms_output.put_line('el codigo del departamento es : ' || vNumDepto);
dbms_output.put_line('el codigo del departamento es : ' || vNomDepto);
end

No hay comentarios:

Publicar un comentario