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
| declare curs_operations cursor IS select ope_cpt from t_operations;
declare test varchar;
begin
--test = fetch 0 from curs_operations
--fetch from curs_operations
--open curs_operations ;
open curs_operations ;
fetch last from curs_operations into test;
insert into t_soldes
values (default,
(select ope_cpt from t_operations, t_comptes where ope_cpt=test),
(select sum(ope_cre) from t_operations,t_comptes where ope_val='TRUE' and cpt_num=test),
(select sum(ope_deb) from t_operations,t_comptes where ope_val='TRUE' and cpt_num=test),
(select coalesce(sum(ope_cre),'0.00') from t_operations,t_comptes where ope_val='FALSE' and cpt_num=test),
(select coalesce(sum(ope_deb),'0.00') from t_operations,t_comptes where ope_val='FALSE' and cpt_num=test),
(select sum(ope_cre)-sum(ope_deb) from t_operations,t_comptes where ope_val='TRUE' and cpt_num=test)
);
--return test;
close curs_operations;
--fin
return new;
end; |
Partager