Hi everyone;
I’m trying to add a SQL sentence in a email triggered alert using the Advanced Alert Manager. The problem is with any string SW variables, in my case is with ${UniqueID} located in the SQL VIEW named CustomPollerStatusTable.
The SQL sentence in the email alert is:
Alert Sentence: ${SQL:SELECT Value FROM CustomPollerStatusTable INNER JOIN CustomPollers ON CustomPollerStatusTable.PollerID = CustomPollers.CustomPollerID WHERE UniqueName = 'GBAvailable' AND UniqueID=${UniqueID}}
Parse Expected: SELECT Value + ' GB' FROM CustomPollerStatusTable INNER JOIN CustomPollers ON CustomPollerStatusTable.PollerID = CustomPollers.CustomPollerID WHERE UniqueName = 'GBAvailable' AND UniqueID=9D8ACCF6-BA7F-4FF0-8512-CF3A110ECD31
Result in the email sent: MACRO SQL ERROR - Incorrect syntax near '9D8'.
As you can see it will fail because legally in SQL the SW variable should be surrounded it by quotes.
Now if we add the quotes:
Alert Sentence: ${SQL:SELECT Value FROM CustomPollerStatusTable INNER JOIN CustomPollers ON CustomPollerStatusTable.PollerID = CustomPollers.CustomPollerID WHERE UniqueName = 'GBAvailable' AND UniqueID='${UniqueID}'}
Parse Expected: SELECT Value + ' GB' FROM CustomPollerStatusTable INNER JOIN CustomPollers ON CustomPollerStatusTable.PollerID = CustomPollers.CustomPollerID WHERE UniqueName = 'GBAvailable' AND UniqueID='9D8ACCF6-BA7F-4FF0-8512-CF3A110ECD31'
Result in the email sent: ${SQL:SELECT Value + ' GB' FROM CustomPollerStatusTable INNER JOIN CustomPollers ON CustomPollerStatusTable.PollerID = CustomPollers.CustomPollerID WHERE UniqueName = 'GBAvailable' AND UniqueID='$@UniqueID@'}
As you can see it fails again by sending the SQL statement and not executing it at all.
Do you have any ideas on how to set a SW string type variable into a SQL statement?
Thanks in advance!