结账提示不能插入重复值
金蝶云社区-云社区用户05hX1234
云社区用户05hX1234
1人赞赏了该文章 1,751次浏览 未经作者许可,禁止转载编辑于2014年12月16日 10:39:50

问题处理1、通过数据库跟踪,提示不能在表T_cc_stock主键插入重复值,开始不知道是哪个键值重复,于是到企业管理器里面修改这个表不受主键约束,结帐通过,通过下面这段代码找出重复值
select fyear,fperiod,fstockid,fitemid,fbatchno,fauxpropid from t_cc_stock group by fyear,fperiod,fstockid,fitemid,fbatchno,fauxpropid having count(*)>1
发现有两条重复,不知道为什么金蝶商贸版在使用日期管理的时候,同一个批号可以录入不同的开始日期和结束日期,也许是金蝶商贸版的一个BUG吧,因为在期抹结帐时提取的分组求和字段有这两个字段fperioddate,fkfdate,
2、找出两个相同的记录,修改批号对应同等的开始和结束日期后,期末结帐通过

select fitemid,fbatchno,fauxpropid,min(fkfdate) as
fkfdate,min(fperioddate) as fperioddate into temp1
from t_cc_stockbillentry
group by fitemid ,fbatchno,fauxpropid

update a set a.fkfdate=b.fkfdate,a.fperioddate=b.fperioddate from
t_cc_stockbillentry a inner join temp1 b on a.fitemid=b.fitemid and a.fbatchno=b.fbatchno and a.fauxpropid=b.fauxpropid

update a set a.fkfdate=isnull(b.fkfdate,'1900-01-01 00:00:00.000'),a.fperioddate=isnull(b.fperioddate,'1900-01-01 00:00:00.000')
from t_cc_stock a inner join temp1 b on a.fitemid=b.fitemid and a.fbatchno=b.fbatchno and a.fauxpropid=b.fauxpropid

drop table temp1

=====================
=====================
update t_icitem set fiskfperiod=0,fkfperiod=0 where ftrack<>80

update a set a.fkfdate=null,a.fperioddate=null,a.fkfperiod=0 from t_cc_stockbillentry a inner join t_icitem b on a.fitemid=b.fitemid where b.ftrack<>80

update c set c.fkfdate='1900-01-01',c.fperioddate='1900-01-01',c.fkfperiod=0 from t_cc_stockbillentry c inner join t_icitem d on c.fitemid=d.fitemid where d.ftrack<>80