oracle存储过程实例(二)

create or replace procedure P_PROBLEM_ZZCJS_gj(pksettleh in varchar2) is
begin
–更新归集子表,根据周转材主表主键
update bpm_cm_realcost_b b
set RTOTALBASEMNY =
(select THISMONEY
from bpm_circul_settle
where dr = 0
and pk_circul_settle = b.pk_subvaluedetail),
MTAXES =
(select taxmny
from bpm_circul_settle
where dr = 0
and pk_circul_settle = b.pk_subvaluedetail),
NOTRTOTALBASEMNY =
(select nottaxmny
from bpm_circul_settle
where dr = 0
and pk_circul_settle = b.pk_subvaluedetail)
where b.pk_subvaluedetail in
(select pk_circul_settle
from bpm_circul_settle
where dr = 0
and pk_settleh = pksettleh)
and b.dr=‘0’;
–更新归集主表,根据周转材主表主键
update bpm_cm_realcost
set COSTVALUE =
(select sum(RTOTALBASEMNY)
from bpm_cm_realcost_b b
where b.pk_subvaluedetail in
(select pk_circul_settle
from bpm_circul_settle
where dr = 0
and pk_settleh = pksettleh)),
MTAXES =
(select sum(MTAXES)
from bpm_cm_realcost_b b
where b.pk_subvaluedetail in
(select pk_circul_settle
from bpm_circul_settle
where dr = 0
and pk_settleh = pksettleh)),
NOTCOSTVALUE =
(select sum(NOTRTOTALBASEMNY)
from bpm_cm_realcost_b b
where b.pk_subvaluedetail in
(select pk_circul_settle
from bpm_circul_settle
where dr = 0
and pk_settleh = pksettleh))
where pk_realcost =(select b.pk_realcost
from bpm_cm_realcost_b b
where b.pk_subvaluedetail in
(select pk_circul_settle
from bpm_circul_settle
where dr = 0
and pk_settleh = pksettleh) group by b.pk_realcost)
and dr=0;
commit;
end;

猜你喜欢

转载自blog.csdn.net/qq_40403688/article/details/89211340
今日推荐