Especificación del Paquete: create or replace package pk_ventas is procedure ventasxvendedor; procedure ventasxdepartamento; function ventasxciudad (codigo_ciudad number) return number; end;
Cuerpo del Paquete: create or replace package body pk_ventas is procedure ventasxvendedor is nombre varchar2 (50); total number; cursor cursor1 is select nom_vendedor,sum(val_factura) as total from vendedor,cliente,factura where vendedor.cod_vendedor=cliente.cod_vendedor and cliente.cod_cliente=factura.cod_cliente group by nom_vendedor; begin for registro in cursor1 loop imprimir(registro.nom_vendedor||' '||registro.total); end loop; end; procedure ventasxdepartamento is nombre varchar2 (50); total number; cursor cursor1 is select nom_departamento,sum(val_factura) as total from departamento,ciudad,cliente,factura where departamento.cod_departamento=ciudad.cod_departamento and cliente.cod_ciudad=ciudad.cod_ciudad and cliente.cod_cliente=factura.cod_cliente group by nom_departamento; begin for registro in cursor1 loop imprimir(registro.nom_departamento||registro.total); end loop; end; function ventasxciudad(codigo_ciudad number) return number is total number; begin
select sum(val_factura)into total from ciudad,cliente,factura where ciudad.cod_ciudad=cliente.cod_ciudad and cliente.cod_cliente=factura.cod_cliente and ciudad.cod_ciudad=codigo_ciudad group by ciudad.cod_ciudad; return total; end; end;
Pantallas del Resultado