Submit a ticketCall us
Home > Success Center > Server & Application Monitor (SAM) > SAM - Knowledgebase Articles > Pull individual numeric values from a multi-value script

Pull individual numeric values from a multi-value script

Overview

You want to pull individual numeric values from a multi-value script.

Environment

All SAM versions

Resolution

The following function works for numeric data:

CREATE FUNCTION [dbo].[apm_Custom_GetMultiValueCurrentnumericdata] (
       @ComponentID int,
       @RowNumber int
 )
 RETURNS nvarchar(max)
 AS
 BEGIN
       DECLARE @result nvarchar(max)
       SELECT @result = Temp.NumericData FROM
       (
             SELECT RANK() OVER (ORDER BY DynEvDef.ID) AS Row, DynEvData.NumericData
             FROM dbo.APM_DynamicEvidence_DetailData AS DynEvData
             INNER JOIN dbo.APM_CurrentComponentStatus AS CCS
                 ON CCS.ComponentStatusID = DynEvData.ComponentStatusID
             INNER JOIN dbo.APM_DynamicEvidenceColumnSchema AS DynEvDef
                 ON DynEvDef.ID = DynEvData.ColumnSchemaID
             WHERE DynEvDef.[Type] = 1 AND CCS.ComponentID = @ComponentID
       ) Temp
       WHERE Temp.Row = @RowNumber
       RETURN @result
 END

At this point, you can use the following inline SQL macro in the Alert Manager to get the first value

${SQL:select dbo.apm_Custom_GetMultiValueCurrentnumericdata(${ComponentId}, 1)}

 

 

Last modified

Tags

Classifications

Public