deleted 和 inserted 是逻辑(概念)表。
deleted 和 inserted 是逻辑(概念)表。这些表在结构上类似于定义触发器的表(也就是在其中尝试用户操作的表);这些表用于保存用户操作可能更改的行的旧值或新值。例如,若要检索 deleted 表中的所有值,请使用: SELECT *FROM deletedCREATE TRIGGER TR_L
deleted 和
inserted 是逻辑(概念)表。这些表在结构上类似于定义触发器的表(也就是在其中尝试用户操作的表);这些表用于保存用户操作可能更改的行的旧值或新值。例如,若要检索
deleted 表中的所有值,请使用:
SELECT *
FROM deleted
CREATE TRIGGER TR_LKCRM_SQJBXXINS
ON dbo.LKCRM_SQSP_SQJBXX
FOR INSERT
AS
BEGIN
DECLARE CUR_LKCRM_SQJBXXINS CURSOR FOR SELECT INS.SQXH,INS.DYXH,INS.SQLB FROM INSERTED INS
DECLARE @SQXH INT
DECLARE @DYXH INT
DECLARE @SQLB NVARCHAR(2)
OPEN CUR_LKCRM_SQJBXXINS
FETCH NEXT FROM CUR_LKCRM_SQJBXXINS INTO @SQXH,@DYXH,@SQLB
WHILE @@FETCH_STATUS = 0
BEGIN
IF @SQLB='01' OR @SQLB='04'
UPDATE LKCRM_DD_DDXX SET SPTGBZ='0' WHERE DDXH=@DYXH
ELSE
BEGIN
IF @SQLB='02'
UPDATE LKCRM_DD_THDXX SET SPTGBZ='0' WHERE THDXH=@DYXH
ELSE
BEGIN
IF @SQLB='03'
UPDATE LKCRM_SC_SCHDJL SET SPTGBZ='0' WHERE HDXH=@DYXH
END
END
FETCH NEXT FROM CUR_LKCRM_SQJBXXINS INTO @SQXH,@DYXH,@SQLB
END
CLOSE CUR_LKCRM_SQJBXXINS DEALLOCATE CUR_LKCRM_SQJBXXINS
END
原文转自:http://www.ltesting.net
|