--按照组织修复错误的数据历史数据,我已经修复了其中的一个组织,那个组织12月没有结账;有的组织12月份已经结账了,使用的脚本不一样;--资产是从2013年开始使用的,也就是需要从2013年12月开始修复。--首先,在固定资产的月末结账节点查看该组织2016年12月份是否结账,如果没有结账,按照下面的步骤执行脚本:--1.查组织主键selectpk_financeorgfromorg_financeorgwherecode='组织编码';--2.查账簿主键selectpk_accountingbookfromorg_accountingbookwherecode='账簿编码';--3.请备份fa_cardhistorycreatetablefa_cardhistory_20170119asselect*fromfa_cardhistorywherepk_org='组织主键'andpk_accbook='账簿主键'anddr=0;--4.修复2013年11月份本年折旧错误脚本:通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据(如果没有说明11月份没有问题,执行下一步)select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2013andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2013andperiod=11andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--5.修复2013年12月份本年折旧错误脚本(修复完11月数据才能执行):通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据:select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2014andperiod=01andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2013andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--6.修复2014年11月份本年折旧错误脚本:通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据(如果没有说明11月份没有问题,执行下一步)select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2014andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2014andperiod=11andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--7.修复2014年12月份本年折旧错误脚本(修复完11月数据才能执行):通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据:select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2015andperiod=01andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2014andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--8.修复2015年11月份本年折旧错误脚本:通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据(如果没有说明11月份没有问题,执行下一步)select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2015andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2015andperiod=11andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--9.修复2015年12月份本年折旧错误脚本(修复完11月数据才能执行):通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据:select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2016andperiod=01andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2015andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--10.修复2016年11月份本年折旧错误脚本:通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据(如果没有说明11月份没有问题,执行下一步)select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2016andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2016andperiod=11andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--11.修复2016年12月份本年折旧错误脚本(修复完11月数据才能执行):通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据:select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='Y'andaccyear=2016andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2016andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--12提交commit;--其次,在固定资产的月末结账节点查看该组织2016年12月份是否结账,如果已经结账,按照下面的步骤执行脚本:--1.查组织主键selectpk_financeorgfromorg_financeorgwherecode='组织编码';--2.查账簿主键selectpk_accountingbookfromorg_accountingbookwherecode='账簿编码';--3.请备份fa_cardhistorycreatetablefa_cardhistory_20170119asselect*fromfa_cardhistorywherepk_org='组织主键'andpk_accbook='账簿主键'anddr=0;--4.修复2013年11月份本年折旧错误脚本:通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据(如果没有说明11月份没有问题,执行下一步)select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2013andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2013andperiod=11andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--5.修复2013年12月份本年折旧错误脚本(修复完11月数据才能执行):通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据:select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2014andperiod=01andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2013andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--6.修复2014年11月份本年折旧错误脚本:通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据(如果没有说明11月份没有问题,执行下一步)select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2014andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2014andperiod=11andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--7.修复2014年12月份本年折旧错误脚本(修复完11月数据才能执行):通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据:select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2015andperiod=01andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2014andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--8.修复2015年11月份本年折旧错误脚本:通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据(如果没有说明11月份没有问题,执行下一步)select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2015andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2015andperiod=11andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--9.修复2015年12月份本年折旧错误脚本(修复完11月数据才能执行):通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据:select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2016andperiod=01andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2015andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--10.修复2016年11月份本年折旧错误脚本:通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据(如果没有说明11月份没有问题,执行下一步)select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2016andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2016andperiod=11andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--11.修复2016年12月份本年折旧错误脚本:通过以下脚本自动生成修复错误数据的脚本,执行后SELECT语句后,--再执行结果中返回的update开头的SQL语句即可修复数据(如果没有说明11月份没有问题,执行下一步)select'updatefa_cardhistorysetcurryeardep=depamount+'||curryeardep||'wherepk_cardhistory='''||pk_cardhistory||''';',z.*from(selecta.card_code,a.asset_code,b.depamount,c.curryeardep,a.pk_card,b.pk_cardhistoryfromfa_cardainnerjoin(selectpk_card,curryeardep,depamount,pk_cardhistoryfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2017andperiod=01andpk_org='组织主键'andpk_accbook='账簿主键')bona.pk_card=b.pk_cardinnerjoin(selectpk_card,curryeardepfromfa_cardhistorywheredr=0andlaststate_flag='N'andaccyear=2016andperiod=12andpk_org='组织主键'andpk_accbook='账簿主键')conb.pk_card=c.pk_cardwherea.dr=0andc.curryeardep+b.depamount<>b.curryeardep)z--12提交commit;