业务流程--上查--报出现重复的主键(FRouteId)数据:xxx
问题描述:
在上下查的时候报出现重复的主键(FRouteId)数据:xxxxx错误,如下图:
解决方案:
一、2020年之前的版本,需要检查一下是否取到多个相同FMasterId, 这可能由于归档发生了异常,只有某些表归档了,如果是此情况,则需要把FMasterId下的所有数据要么归档,要么不归档(包括t_bf_instance, t_bf_instanceEntry,t_bf_instanceAmount)。已知的表名@FTTableName ,内码,检查脚本:
--查询@FTTableId Select FSEQ as @FTTableId from t_bf_tableDefine where FTableNumber=@FTTableName --查询当前表 with tb001 as(select FEntryId from t_xxx_Entry(替换为实际的取内码的表)) SELECT TInst.FMasterId FROM t_BF_Instance TInst INNER JOIN t_BF_InstanceEntry TEntry ON (TInst.FInstanceId = TEntry.FInstanceId) INNER JOIN tb001 TIds ON (TEntry.FTId = TIds.FID) WHERE TEntry.FTTableName = @FTTableName --查询历史表 SELECT TInst.FMasterId FROM t_BF_InstanceHis TInst INNER JOIN t_BF_InstanceEntryHis TEntry ON (TInst.FInstanceId = TEntry.FInstanceId) INNER JOIN tb001 TIds ON (TEntry.FTId = TIds.FID) WHERE TEntry.FTTableId = @FTTableId ---查询归档表 SELECT TInst.FMasterId FROM t_BF_InstBackUp TInst INNER JOIN t_BF_InstEntryBackUp TEntry ON (TInst.FInstanceId = TEntry.FInstanceId) INNER JOIN tb001 TIds ON (TEntry.FTId = TIds.FID) WHERE TEntry.FTTableId = @FTTableId
二、如果是之后的版本或不是上面情况,则需要根据上面取到的FMaster集合,再查询具体的节点数据,相关脚本:
--FMasterId来源当前表 with tb002 as(select FInstanceId from t_bf_instance where FMasterId in(xx1,xx2,xx3) --FMasterId来源历史表 with tb002 as(select FInstanceId from t_bf_instanceHis where FMasterId in(xx1,xx2,xx3) --FMasterId来源归档表 with tb002 as(select FInstanceId from t_bf_instBackUp where FMasterId in(xx1,xx2,xx3) --查询当前节点表 SELECT t0.FRouteId, t0.FInstanceId, t0.FLineId, t0.FSTableName, t0.FSId, t0.FTTableName, t0.FTId, t0.FFirstNode, t0.FCreateTime FROM tb002 t3 INNER JOIN t_BF_InstanceEntry t0 ON t3.FInstanceId =t0.FInstanceId --查询历史节点表 SELECT t0.FRouteId, t0.FInstanceId, t0.FLineId, ISNULL(t1.FTableNumber, ' ') AS FSTableName, t0.FSId, ISNULL(t2.FTableNumber, ' ') AS FTTableName, t0.FTId, t0.FFirstNode, t0.FCreateTime FROM tb002 t3 INNER JOIN t_BF_InstanceEntryHis t0 ON t3.FInstanceId =t0.FInstanceId LEFT JOIN t_BF_TableDefine t1 ON (t0.FSTableId = t1.FSeq and t1.FSeq <> 0) LEFT JOIN t_BF_TableDefine t2 ON (t0.FTTableId = t2.FSeq and t2.FSeq <> 0) --查询历史归档表 SELECT t0.FRouteId, t0.FInstanceId, t0.FLineId, ISNULL(t1.FTableNumber, ' ') AS FSTableName, t0.FSId, ISNULL(t2.FTableNumber, ' ') AS FTTableName,t0.FTId, t0.FFirstNode, t0.FCreateTime FROM tb002 t3 INNER JOIN t_BF_InstEntryBackUp t0 ON t3.FInstanceId =t0.FInstanceId LEFT JOIN t_BF_TableDefine t1 ON (t0.FSTableId = t1.FSeq and t1.FSeq <> 0) LEFT JOIN t_BF_TableDefine t2 ON (t0.FTTableId = t2.FSeq and t2.FSeq <> 0)
三、最后的结果,很可能是表定义中存在相同的表序号
select Fseq from t_bf_tableDefine where Group by Fseq having count(1)>1
四、如果是存在相同的表序号,则需要把一个序号修改掉,并且把历史和归档中的数据也更新
修改表序号原则是取表中最大的序号+1,更新语句如下,假设更新后的序号为maxFseq:
update t_bf_tableDefine FSeq=max(Fseq)+1 where FTableNumber='xxxx'
更新相关历史,归档节点表数据,假设:
1)LK表为: xxx_LK,
2) 本地表序号: tFeqxx
3) 更新用的序号:maxFseq
4)上游来源表名:t_xxx_StbName
5)上游来源表序号:sFeqxx, 查询脚本:
select FSeq from t_bf_tableDefine where FTableNumber='t_xxx_StbName'
--更新历史节点表 update t_bf_instanceEntryHis set FTTableId=maxFseq where FTTableId=tFeqxx and FSTableId= sFeqxx and FTId in(select FEntryId from xxx_LK) and FSId in (select FSId from xxx_LK where FSTableName='t_xxx_StbName') --更新归档节点表 update t_bf_instEntryBackUp set FTTableId=maxFseq where FTTableId=tFeqxx and FSTableId= sFeqxx and FTId in(select FEntryId from xxx_LK) and FSId in(select FSId from xxx_LK where FSTableName='t_xxx_StbName')
业务流程--上查--报出现重复的主键(FRouteId)数据:xxx
问题描述:在上下查的时候报出现重复的主键(FRouteId)数据:xxxxx错误,如下图:解决方案:一、2020年之前的版本,需要检查一下是否取到多个...
点击下载文档
本文2024-09-23 03:37:34发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-160050.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章