解决方案: |
因为客户余额明细表和客户动态汇总表的来源都是同一帐户,在按同日期查询时,余额就应一致,您所说的不一致,是哪个表的哪个项目,哪个帐户不一致,都没有描述,请试一下重新定义项目并指定它的帐户来源,是否一致?
1)可以根据fd_accbal计算:
update fd_accsum
set mb=a.bal_mny
from fd_accsum
inner join fd_accbal a on fd_accsum.dbill_date=a.bill_date and fd_accsum.accdef_id=a.accdef_id
update fd_accsum
Set mh=a.mh+fd_accsum.mb from fd_accsum a,fd_accsum
where datediff(day,a.dbill_date,fd_accsum.dbill_date)=1 and a.accdef_id=fd_accsum.accdef_id
2)经查确实如此,在fd_accbal表中,期初的数据无本位币金额造成的。有脚本解决:
if exists (select 1 from sysobjects where id=object_id('fd_accdef') and type='u')
begin
alter table fd_accdef disable trigger fd_accdef_delete
alter table fd_accdef disable trigger fd_accdef_insert
alter table fd_accdef disable trigger fd_accdef_update --
UPDATE fd_accdef SET qcye_natural_mny = mb
对于本位币的帐户,可以用语句更新:
update fd_accdef set qcye_natural_mny=mb,qcjs_natural_mny=mh
where cexch_name='人民币' and mb<>qcye_natural_mny or mh<>qcjs_natural_mny
alter table fd_accdef enable trigger fd_accdef_delete
alter table fd_accdef enable trigger fd_accdef_insert
alter table fd_accdef enable trigger fd_accdef_update
end
go
---- 更改余额表的本位币数值
update fd_accbal
set natural_rcv_mny = rcv_mny , natural_rcv_booked_mny = rcv_booked_mny, natural_pay_mny = pay_mny ,
natural_pay_booked_mny = pay_booked_mny, natural_bal_mny =bal_mny,natural_bal_booked_mny =bal_booked_mny
网上已经有期初本位币余额为零问题.txt的补丁脚本.
3)发现有注销的帐户存在与fd_accsum表中。可以先把其删除。
SELECT caccid,MAX(FD_AccSum.dbill_date) AS dbill_date into tmpa
FROM FD_AccSum
GROUP BY FD_AccSum.cAccID
having MAX(FD_AccSum.dbill_date)<'2004-12-31'
go
delete from fd_accsum
where caccid in (select caccid from tmpa)
go
drop table tmpa
go
在做以上操作时,要先备份好数据,问题1要确认是客户余额动态汇总表和帐户余额日报表的数据是正确的,只是客户余额资金明细表数据不对,才可以执行。 |