//2、汇总二级会计科目余额
declare c2 cursor for
select zz_kmyeb.km_code,yefx_code from zz_kmyeb ,zz_kjkmbmb
where zz_kmyeb.zth=zz_kjkmbmb.zth and zz_kmyeb.km_code=zz_kjkmbmb.km_code
and zz_kmyeb.zth=:r_zth and nkjqj=:r_nkjqj and ykjqj=:r_ykjqj and kmjb=2 and mjbj_code='N' ;
open c2;
fetch c2 into :r_km_code,:r_yefx_code;
do while sqlca.sqlcode=0
select sum(qcjfye), sum(qcdfye) into :r_qcjfye , :r_qcdfye
from zz_kmyeb ,zz_kjkmbmb
where zz_kmyeb.zth=zz_kjkmbmb.zth and zz_kmyeb.km_code=zz_kjkmbmb.km_code
and zz_kmyeb.zth=:r_zth and nkjqj=:r_nkjqj and ykjqj=:r_ykjqj
and substring(zz_kmyeb.km_code,1,6)=:r_km_code and mjbj_code='Y' ;
CHOOSE CASE r_yefx_code
CASE '借'
r_qcye=r_qcjfye - r_qcdfye
CASE '贷'
r_qcye= r_qcdfye - r_qcjfye
END CHOOSE
update zz_kmyeb
set qcjfye=:r_qcjfye,qcdfye=:r_qcdfye,qcye=:r_qcye,
qmjfye=:r_qcjfye,qmdfye=:r_qcdfye,qmye=:r_qcye
from zz_kmyeb,zz_kjkmbmb
where zz_kmyeb.zth=zz_kjkmbmb.zth and zz_kmyeb.km_code=zz_kjkmbmb.km_code
and zz_kmyeb.zth=:r_zth and nkjqj=:r_nkjqj and ykjqj=:r_ykjqj
and zz_kmyeb.km_code=:r_km_code and kmjb=2 and mjbj_code='N' ;
fetch c2 into :r_km_code,:r_yefx_code;
loop
close c2;
窗口设计说明
1. 会计科目余额查询窗口w_kmyeb_cx,如下表2-8-4所示。
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] 下一页