触发器:处理偶发性销售订单变更单FOBJECTTYPEID异常

栏目:云星空知识作者:金蝶来源:金蝶云社区发布:2024-09-23浏览:1

触发器:处理偶发性销售订单变更单FOBJECTTYPEID异常



因一些特殊场景或未知场景的导致的偶发性销售订单新变更单T_SAL_XORDER.FOBJECTTYPEID异常(正确值为SAL_XORDER,异常值为SAL_SaleOrder),除直接修复数据外,可使用以下触发器杜绝





IF EXISTS (SELECT 1 FROM SYS.triggers WHERE NAME = 'TR_REPAIR_XORDER_OBJ') DROP TRIGGER TR_REPAIR_XORDER_OBJ;
GO
IF NOT EXISTS (SELECT 1 FROM SYS.all_objects WHERE NAME = 'TR_REPAIR_XORDER_OBJ_LOG' AND TYPE ='U') CREATE TABLE TR_REPAIR_XORDER_OBJ_LOG (FID INT,UP_DATE DATETIME);
GO

CREATE TRIGGER TR_REPAIR_XORDER_OBJ ON T_SAL_XORDER
FOR INSERT,UPDATE
AS
IF UPDATE(FOBJECTTYPEID)
BEGIN
    DECLARE @CON INT;
    SELECT @CON = COUNT(1) FROM inserted WHERE FOBJECTTYPEID <> 'SAL_XORDER';
    IF @CON > 0
        BEGIN
        INSERT INTO TR_REPAIR_XORDER_OBJ_LOG SELECT INS.FID,GETDATE() FROM inserted INS WHERE INS.FOBJECTTYPEID <> 'SAL_XORDER';
        UPDATE T_SAL_XORDER SET FOBJECTTYPEID = 'SAL_XORDER' WHERE FID IN (SELECT INS.FID FROM inserted INS WHERE INS.FOBJECTTYPEID <> 'SAL_XORDER');
        END;    
END;


触发器:处理偶发性销售订单变更单FOBJECTTYPEID异常

因一些特殊场景或未知场景的导致的偶发性销售订单新变更单T_SAL_XORDER.FOBJECTTYPEID异常(正确值为SAL_XORDER,异常值为SAL_SaleOrder)...
点击下载文档
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息