Quantcast
Channel: THWACK: Popular Discussions - Web Performance Monitor (formerly SeUM)
Viewing all articles
Browse latest Browse all 12861

Using CASE or IF statements in a 'defined SQL variable' for use in the message body of Alert email action...

$
0
0

This is an example of the altert email message:

 

**************************************************************************************************************************

${DateTime}

 

WEB TRANSACTION ${TransactionId}: ${Name}

LAST PLAYED: ${LastPlayed}


PLAYBACK INTERVAL: ${SQL:Select ${PlaybackInterval}/60} min

TRANSACTION STATUS: ${Status}
TRANSACTION DURATION: ${SQL:Select CAST(ROUND(${Duration}, 2, 1) AS DECIMAL(8, 2))} sec

 

STEPS WITH PROBLEMS:
${StepsWithProblemsFormatted}

**************************************************************************************************************************

 

Problem:

1. When the ${Status} is equal to Down... I get an SQL error message like the example below :

 

TRANSACTION STATUS: Down

TRANSACTION DURATION: MACRO SQL ERROR - Incorrect syntax near ','. sec

 

2. When the ${Status} is equal to Warning or Critical or UP... I get a nice formated Duration time like the example below :

 

TRANSACTION STATUS: Warning

TRANSACTION DURATION: 11.70 sec

***************************************************************************************************************************

My attempt to resolve was to offer an alternative to when the Duration would not have a time... as in a Down situation.

Can any of this be done like I have been trying to do using a CASE or IF statement?

 

The STATUS for these results was WARNING:

A
${SQL: Select CASE $Status WHEN $Status = 'Down' THEN '*****DOWN*****'
ELSE CAST(ROUND($Duration,2,1) AS DECIMAL(8,2)) END} sec

Result in email:

${SQL: Select CASE $Status WHEN $Status = 'Down' THEN '*****DOWN*****'

ELSE CAST(ROUND($Duration,2,1) AS DECIMAL(8,2)) END} sec

 

B
${SQL: Select CASE ${Status} WHEN ${Status} = 'Down' THEN '*****DOWN*****'
ELSE CAST(ROUND(${Duration},2,1) AS DECIMAL(8,2)) END} sec

Result in email:

${SQL: Select CASE $@Status@ WHEN $@Status@ = 'Down' THEN '*****DOWN*****'

ELSE CAST(ROUND($@Duration@,2,1) AS DECIMAL(8,2)) END} sec

 

C
${SQL:Select IF '${Status}' = 'Down' THEN 'Down' ELSE (CAST(ROUND(${Duration},2,1) AS DECIMAL(8,2)) END)} sec

Result in email:

MACRO SQL ERROR - Incorrect syntax near the keyword 'IF'.

Incorrect syntax near the keyword 'THEN'. sec

 

D
${SQL:Select IF (${Status} = 'Down' ) THEN 'Down' ELSE (CAST(ROUND(${Duration},2,1) AS DECIMAL(8,2)) END)} sec

Result in email:

MACRO SQL ERROR - Incorrect syntax near the keyword 'IF'.

Incorrect syntax near the keyword 'THEN'. sec

 

E
${SQL:Select CASE '${Status}' WHEN 'Down' THEN '***** DOWN *****' ELSE CAST (ROUND (${Duration},2,1) AS DECIMAL (8,2)) END} sec

Result in email: 25.71 sec<-- Good result for Warning but not sure it would work when DOWN.


Viewing all articles
Browse latest Browse all 12861

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>