1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| declare
cursor c_prevu(date_debut date) is
select montant_du,
to_char(date_fin_contrat,'dd/mm/yyyy')
from contrats
where nvl(date_fin_contrat,'31/12/2050') >=date_debut;
v_montant number(10);
v_date_fin_contrat date;
date_debut date:=:debut;
begin
while date_debut<=:fin loop
open c_prevu(date_debut);
fetch c_prevu into v_montant,v_date_fin_contrat;
while c_prevu%found loop
if nvl(v_date_fin_contrat,'31/12/2050') >=date_debut
then insert into echeance(mois,annee,montant_total)
values(to_char(date_debut,'DD'),
to_char(date_debut,'MM'),
v_montant);
end if;
fetch c_prevu into v_montant,v_date_fin_contrat;
end loop;
date_debut:=add_months(date_debut,1);
close c_prevu;
end loop;
commit;
end; |
Partager