解决方案: |
currentstock_ind的唯一约束不能插入重复的值。即:因在Currentstock表中的Dvdate有重复的值,使年度结转不能正常进行。
因为用户在平时录如单据时,有过同一仓库、存货、批次的存货生产日期和失效日期不同,造成在currentstock表中的记录重复。且去年的数据也丢失了上述约束。
解决方法1:用脚本把同一仓库、存货、批次但失效日期不同的记录查出,在失效期管理中把其调整成一致的。再整理现存量。
select cInvCode, cWhCode, cBatch, cFree1, cFree2, cFree3, cFree4, cFree5,
cFree6, cFree7, cFree8, cFree9, cFree10, count* as num
from CurrentStock
group by cInvCode, cWhCode, cBatch, cFree1, cFree2, cFree3, cFree4, cFree5, cFree6, cFree7, cFree8, cFree9, cFree10 having count*>1
方法2:把整理现存量脚本sp_clearcurrentstock_st中的相关创建tempaa 的部分中的dmdate去掉,可以重新整理现存量,把数据库中的重复记录自动合并。
存储过程SP_clearcurrentstock 中有以下一段内容:
select cWhCode,cInvCode,cFree1,cFree2,cfree3,cfree4,cfree5,cfree6,
cfree7,cfree8,cfree9,cfree10,cbatch,maxdvdate as dvdate,dmdate,imassdate
into tempAA
from tempcurrentstock group by cWhCode,cInvCode,cFree1,cFree2,cfree3,cfree4,cfree5,cfree6,cfree7,cfree8,cfree9,cfree10,cbatch,dmdate,imassdate
' currentstock_ind的唯一约束不能插入重复的值。即:因在Currentstock表中的Dvdate有重复的值,使年度结转不能正常进行。因为用户在平时录如单据时,有过同一仓库、存货、批次的存货生产日期和失效日期不同,造成在currentstock表中的记录重复。且去年的数据也丢失了上述约束。 |