业务流程相关脚本sql原创
14人赞赏了该文章
2,252次浏览
编辑于2022年03月19日 09:34:39
业务流程有些脏数据可能一时不清楚产生原因,需要做一些清理,清理sql如下:
1. 执行计划归档报插入重复性错误,直接删除历史表数据即可
--删除存在当前表中的历史表反写值 delete from T_BF_INSTANCEAMOUNTHIS where FRouteId in(select FRouteId from T_BF_INSTANCEAMOUNT ) --删除存在当前表的节点值 delete from T_BF_INSTANCEEntryHis where FRouteId in(select FRouteId from t_BF_InstanceEntry ) --删除存在当前表的实例值 delete from T_BF_INSTANCEHis where FInstanceId in(select FInstanceId from t_BF_Instance )
2. 在操作时,如果堆栈中有报对象引用错误,即get_Instance()这样的情况,则存在没有实例的节点,需要把这样的节点删除或者创建实例
--清理没有实例的节点 delete from t_bf_instanceentry where finstanceid not in (select finstanceid from t _bf_instance)
3. 清理表单被删除的反写规则
--清除多语言 delete from T_BF_WRITEBACKRULE_L where FID in( select FID from T_BF_WRITEBACKRULE where FSOURCEFORMID not in(select FID from T_META_OBJECTTYPE)) delete from T_BF_WRITEBACKRULE_L where FID in( select FID from T_BF_WRITEBACKRULE where FTARGETFORMID not in(select FID from T_META_OBJECTTYPE)) --清除反写规则 delete from T_BF_WRITEBACKRULE where FSOURCEFORMID not in(select FID from T_META_OBJECTTYPE) delete from T_BF_WRITEBACKRULE where FTARGETFORMID not in(select FID from T_META_OBJECTTYPE)
4. 清理不存在实际单据数据的节点
--首先根据表单找出表名,假设为销售订单,T_SAL_ORDERENTRY select t0.FTABLENUMBER from T_BF_TABLEDEFINE t0 inner join T_META_OBJECTTYPE_L t1 on t0.FFORMID=t1.FID where t1.FNAME='销售订单' and FLOCALEID=2052 --根据表名找到不存在实际数据的节点 select * from t_bf_instanceEntry where FTTABLENAME='T_SAL_ORDERENTRY' and FTID not in(select FENTRYID from T_SAL_ORDERENTRY) --删除节点数据 delete from t_bf_instanceEntry where FTTABLENAME='T_SAL_ORDERENTRY' and FTID not in(select FENTRYID from T_SAL_ORDERENTRY)
5. 清理不存在实际单据的转换规则
delete from T_meta_ConvertRule where FSOURCEFORMID not in(select FID from T_META_OBJECTTYPE) or FTARGETFORMID not in(select FID from T_META_OBJECTTYPE) delete from T_meta_ConvertRule_L where fid not in(select FID from T_meta_ConvertRule)
6、查询是否有归档条件的业务流程实例
SELECT TOP 10000 ROW_NUMBER() OVER(ORDER BY inst0.FInstanceId) AS FId, inst0.FInstanceId AS FInstanceId FROM t_BF_Instance inst0 INNER JOIN t_BF_Instance inst1 ON (inst0.FInstanceId = inst1.FMasterId) INNER JOIN t_BF_InstanceEntry instEntry ON (inst1.FInstanceId = instEntry.FInstanceId) GROUP BY inst0.FInstanceId HAVING max(instEntry.FCreateTime) < '当前时间减去设置值'
赞 14
14人点赞
还没有人点赞,快来当第一个点赞的人吧!
打赏
0人打赏
还没有人打赏,快来当第一个打赏的人吧!