Ver Mensaje Individual
  #6 (permalink)  
Antiguo 12/12/2007, 15:44
yermatron
 
Fecha de Ingreso: diciembre-2007
Ubicación: Coronel
Mensajes: 4
Antigüedad: 16 años, 5 meses
Puntos: 0
Re: Ayuda con una función

Muuuchas gracias seyko me a funcionado realmente estoy muy agradecido por el tiempo brindado en ayudarme.

Ahora lo de mí profesor estaría muy a gusto en tirarle las orejas y unas cosas más cuando algo no me sale, pero creo que he aprendido mucho con las dificultades que nos pone.. En fin gran aporte por la resolución.

Estan muy buenos los demas temas igual me han prestado de ayuda en algunas otras grandes dudas :)....

Cita:
Iniciado por yermatron Ver Mensaje
CREATE TYPE ty_multas AS
(
fecha DATE,
n_socio INT,
multa INT,
monto_acum INT,
cant_acum INT
);

create or replace function f_multassocios()
returns setof ty_multas
as
$xD$
declare
num_multa int;
type_multero ty_multas;

begin
for num_multa in select num from multas where pagado ='Si' loop
select fecha_pago into type_multero.fecha
from multas
where num = num_multa;

select n_socio into type_multero.n_socio
from multas
where num = num_multa;

select precio into type_multero.multa
from multas
where num = num_multa;

select sum(precio) into type_multero.monto_acum
from multas
where n_socio = type_multero.n_socio
and fecha_pago <= type_multero.fecha;

select count(*) into type_multero.cant_acum
from multas
where n_socio = type_multero.n_socio
and fecha_pago <= type_multero.fecha;

return next type_multero;
end loop;
RETURN;

END;
$xD$
Language 'Plpgsql';
La he hecho toda denuevo :)