-
Notifications
You must be signed in to change notification settings - Fork 1
/
0_TR_AUDIT.sql
43 lines (35 loc) · 1.01 KB
/
0_TR_AUDIT.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
USE [VBM]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*-Updates the UPDATED_BY & DATE_UPDATED fields when updates occur--*/
CREATE TRIGGER [dbo].[TR_AFT_U_AUDIT_COSTS_OPER_PLAN_MARGIN] ON [dbo].[COSTS_OPER_PLAN_MARGIN]
FOR UPDATE
NOT FOR REPLICATION
AS
BEGIN
DECLARE @errMsg NVARCHAR(2000)
SET XACT_ABORT ON ;
BEGIN TRY
BEGIN TRANSACTION
SET NOCOUNT ON
SET ANSI_NULLS ON
UPDATE COSTS_OPER_PLAN_MARGIN
SET UPDATED_BY = SYSTEM_USER ,
DATE_UPDATED = GETDATE()
FROM COSTS_OPER_PLAN_MARGIN AS A
INNER JOIN INSERTED I
ON I.[ID_PORTFOLIO] = A.[ID_PORTFOLIO] AND I.[PERIOD] = A.[PERIOD] AND I.[DATE_LOAD] = A.[DATE_LOAD] --AND I.[VERSION] = A.[VERSION]
SET NOCOUNT OFF
COMMIT
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK
SELECT @errMsg = 'TR_AFT_U_AUDIT_COSTS_OPER_PLAN_MARGIN '+ERROR_MESSAGE()
RAISERROR (@errMsg, 16,1)
END CATCH
END
GO