USE [HCITools] GO IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[mon_DML_PH_insurance]') AND type in (N'P', N'PC')) DROP PROCEDURE [dbo].[mon_DML_PH_insurance] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[mon_DML_PH_insurance] @in_debug tinyint = 0 AS /*============================================================================= Explication du traitement realise par la SP ------------------------------------------- La SP va rechercher les modifications de DML pour la table PH insurance les derniers 4h Contexte d'utilisation ---------------------- Appelé depuis le job DR90010 - Central Track PH Insurance DML Alerts Parametres ---------- @in_debug : non utilisé Creation : 10.03.21 / RTC Modifications : 11.08.2021 / spe : #TFS65583# Migrate personal email address from [hcisolutions.ch] to [galenica.com] 07.08.2021 / spe : #TFS65583# Migrate personal email address from [hcisolutions.ch] to [galenica.com] - Corrections 16.03.2022 / FLA : Standardisation des mails 23.10.2023 / tsc : #OCTPDBA-792 remove occurences of christophe.dorion@galenicare.com from mailing lists =============================================================================*/ set nocount on; /*------------------- Declaration des variables --------------------*/ DECLARE @subject NVARCHAR(MAX), @html_msg NVARCHAR(MAX), @html_table NVARCHAR(MAX), @currentDate DATETIME /*------------ Affectation des parametres aux variables ------------*/ SET @currentDate = GETDATE() /*-------------------------- Traitement ---------------------------*/ BEGIN TRY SET QUOTED_IDENTIFIER ON /* Run only on centrals for GCM format */ IF NOT EXISTS (SELECT 1 FROM [master].[cfg].[InstanceContext] WHERE [Business] = 'TPCENT') RETURN IF NOT EXISTS (SELECT 1 FROM [master].[cfg].[Identity] WHERE Format = 'GCM') RETURN /* Formatage du message et envoi */ SELECT @subject = @@SERVERNAME + ' - DML audit PH_insurance' SET @html_table = N'' SELECT @html_table = @html_table + '' + '' + ISNULL(DMA_Host_Name,'') + '' + '' + ISNULL(convert(varchar(10), DMA_SPID),'') + '' + '' + ISNULL(DMA_Event_Info,'') + '' + '' + DMA_App_Name + '' + '' + CONVERT(NVARCHAR(25),DMA_Datetime) + '' + '' FROM [master].[dba].[DML_audit] WHERE dma_table_name = 'ph_insurance' AND (@currentDate <= DATEADD(MI,250,DMA_Datetime)) --ORDER BY DMA_Datetime ASC IF @@ROWCOUNT > 0 BEGIN SET @html_msg = N'

PH Insurance DML Audit

' + N'' + N'' + @html_table + N'
Host Name SPID DMA_Event_Info Application Name Update Time
' EXEC Arizona.[dbo].[aps_Send_Mail_with_template] @in_job_type = 0, @in_param_varchar_2 = 'DBA_operator', @in_param_subject = @subject, @in_param_message = @html_msg; END /*---------------------- Traitement des erreurs ----------------------*/ END TRY BEGIN CATCH /* Traitement des erreurs (avec RaiseError) */ EXEC dbo.get_Error_Info @in_RaiseError = 1 END CATCH GO