Deleded and Inserted are logical (concept) table.

xiaoxiao2021-03-06  82

Deleded and

INSERTED is a logical (concept) table. These tables are similar to the table that defines the trigger (that is, the table is attempted to operate); these tables are used to save the old values ​​or new values ​​of the rows that the user can change. For example, if you want to retrieve

All values ​​in the deleted table, please use:

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

转载请注明原文地址:https://www.9cbs.com/read-108120.html

New Post(0)