116 lines
3.6 KiB
Transact-SQL
116 lines
3.6 KiB
Transact-SQL
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 + '<tr style="color:black;background-color:white;">' +
|
|
'<td>' + ISNULL(DMA_Host_Name,'') + '</td>' +
|
|
'<td>' + ISNULL(convert(varchar(10), DMA_SPID),'') + '</td>' +
|
|
'<td>' + ISNULL(DMA_Event_Info,'') + '</td>' +
|
|
'<td>' + DMA_App_Name + '</td>' +
|
|
'<td>' + CONVERT(NVARCHAR(25),DMA_Datetime) + '</td>' +
|
|
'</tr>'
|
|
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'<H3><font color="Black">PH Insurance DML Audit</H3>' +
|
|
N'<table border="1" align="left" cellpadding="2" cellspacing="0" style="color:white;font-family:arial,helvetica,sans-serif;text-align:center;" >' +
|
|
N'<tr style ="font-size: 14px;font-weight: normal;background:black;">
|
|
<th>Host Name</th>
|
|
<th>SPID</th>
|
|
<th>DMA_Event_Info</th>
|
|
<th>Application Name</th>
|
|
<th>Update Time</th>
|
|
</tr>' + @html_table + N'</table>'
|
|
|
|
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
|
|
|
|
|
|
|