问题:执行集团往据点中抛转数据时,发生违反唯一性原则。
这个时候立马就想到,主键重复了。这个时候快速检测了一下前端数据,发现33条有关的数据。
select * from bmba_t where bmbaent = 88 and bmba001 = '100102424' and bmbasite = 'JHG2' order by bmba003
然后去数据库一查,果然,数据大于前台显示的数据,这个时候就发现脏数据还是蛮多的。
只能一个一个区校对了。
细节
主要看一下失效日期,还有一个ECN单号,这基本上脏数据和正确数据唯一不同的地方了。
后面就是一个一个去检查,然后删除掉脏数据,这样插入表的时候就不会报主键错误了。
查看代码就是这个地方报错的。
删除的sql
delete from bmba_t where bmbaent = 88 and bmba003 = '300201639' and bmbasite = 'ALL' and bmba026 is null
delete from bmba_t where bmbaent = 88 and bmba001 = '100102424' and bmba003 = '600101907' and bmbasite = 'ALL' and bmba026 = 'LED-24010125'
delete from bmba_t where bmbaent = 88 and bmba001 = '100102424' and bmba003 = '600102011' and bmbasite = 'ALL' and bmba026 = 'LED-24010118'
delete from bmba_t where bmbaent = 88 and bmba001 = '100102424' and bmba003 = '600102012' and bmbasite = 'ALL' and bmba026 = 'LED-24010117'
验证
脏数据删除之后,在进行bom结构资料的抛转,然后就会发现可以了。
然后正确的抛转到第二个里面了。