The problem is it is not writting to ERROR_LIST table when the update is not done. Can you help me with the syntax.
CREATE TRIGGER SP_A ON dbo.B
FOR INSERT, UPDATE
AS
If UPDATE(STREAM_THROUGHPUT)
BEGIN
-- Declare variables for error handling
DECLARE @ROWCOUNT AS int
DECLARE @RETURN AS int
-----------------------------------------------------------------
Begin
-- loop 1
UPDATE dbo.ESP_MAT_STREAM_INFO
SET dbo.ESP_MAT_STREAM_INFO.VERSION_NO = (SELECT dbo.ESP_MAT_PROPERTY.VERSION_NO
FROM dbo.ESP_MAT_STREAM_INFO INNER JOIN inserted i
ON i.PROCESS_STREAM_ID = dbo.ESP_MAT_STREAM_INFO.PROCESS_STREAM_ID
AND i.BEGIN_DATE < dbo.ESP_MAT_STREAM_INFO.BEGIN_DATE
AND i.END_DATE <= dbo.ESP_MAT_STREAM_INFO.END_DATE
AND i.SITE_ID = dbo.ESP_MAT_STREAM_INFO.SITE_ID
INNER JOIN dbo.ESP_MAT_PROPERTY
ON i.BEGIN_DATE >= dbo.ESP_MAT_PROPERTY.BEGIN_DATE
AND i.END_DATE <= dbo.ESP_MAT_PROPERTY.END_DATE
AND dbo.ESP_MAT_STREAM_INFO.MATCHEM_ID = dbo.ESP_MAT_PROPERTY.MATCHEM_ID)
FROM dbo.ESP_MAT_STREAM_INFO INNER JOIN inserted i
ON i.PROCESS_STREAM_ID = dbo.ESP_MAT_STREAM_INFO.PROCESS_STREAM_ID
AND i.BEGIN_DATE >= dbo.ESP_MAT_STREAM_INFO.BEGIN_DATE
AND i.END_DATE <= dbo.ESP_MAT_STREAM_INFO.END_DATE
AND i.SITE_ID = dbo.ESP_MAT_STREAM_INFO.SITE_ID
-- Error handling process start for loop 1
SELECT @ROWCOUNT = @@ROWCOUNT
INSERT INTO ERROR_LIST (IN_UP_ROWCOUNT) values (@ROWCOUNT)
END
END
CREATE TRIGGER SP_A ON dbo.B
FOR INSERT, UPDATE
AS
If UPDATE(STREAM_THROUGHPUT)
BEGIN
-- Declare variables for error handling
DECLARE @ROWCOUNT AS int
DECLARE @RETURN AS int
-----------------------------------------------------------------
Begin
-- loop 1
UPDATE dbo.ESP_MAT_STREAM_INFO
SET dbo.ESP_MAT_STREAM_INFO.VERSION_NO = (SELECT dbo.ESP_MAT_PROPERTY.VERSION_NO
FROM dbo.ESP_MAT_STREAM_INFO INNER JOIN inserted i
ON i.PROCESS_STREAM_ID = dbo.ESP_MAT_STREAM_INFO.PROCESS_STREAM_ID
AND i.BEGIN_DATE < dbo.ESP_MAT_STREAM_INFO.BEGIN_DATE
AND i.END_DATE <= dbo.ESP_MAT_STREAM_INFO.END_DATE
AND i.SITE_ID = dbo.ESP_MAT_STREAM_INFO.SITE_ID
INNER JOIN dbo.ESP_MAT_PROPERTY
ON i.BEGIN_DATE >= dbo.ESP_MAT_PROPERTY.BEGIN_DATE
AND i.END_DATE <= dbo.ESP_MAT_PROPERTY.END_DATE
AND dbo.ESP_MAT_STREAM_INFO.MATCHEM_ID = dbo.ESP_MAT_PROPERTY.MATCHEM_ID)
FROM dbo.ESP_MAT_STREAM_INFO INNER JOIN inserted i
ON i.PROCESS_STREAM_ID = dbo.ESP_MAT_STREAM_INFO.PROCESS_STREAM_ID
AND i.BEGIN_DATE >= dbo.ESP_MAT_STREAM_INFO.BEGIN_DATE
AND i.END_DATE <= dbo.ESP_MAT_STREAM_INFO.END_DATE
AND i.SITE_ID = dbo.ESP_MAT_STREAM_INFO.SITE_ID
-- Error handling process start for loop 1
SELECT @ROWCOUNT = @@ROWCOUNT
INSERT INTO ERROR_LIST (IN_UP_ROWCOUNT) values (@ROWCOUNT)
END
END