Hey all,
I am making an alarm page on one of my screens where I can sort alarms by the alarm type, but I would also like to show all of the alarms for the given time range. I have a drop down box with the following SQL statement bound to it:
SELECT DISTINCT STATE_NAME
FROM ALERT_LOG
where displaypath='Kill Floor Alarms'
union all
select 'All'
order by STATE_NAME asc
So that it will pick all of the different alarms that are in the alarm database associated with “Kill Floor Alarms”, I also have it adding an “All” selection to the list.
Now, on my table I have this SQL statement:
SELECT STATE_NAME, ACTIVE_TIMESTAMP, CLEARED_TIMESTAMP, DATEDIFF(minute,ACTIVE_TIMESTAMP,CLEARED_TIMESTAMP) as Downtime
FROM ALERT_LOG
WHERE displaypath='Kill Floor Alarms'
and STATE_NAME='{Root Container.Dropdown 1.selectedStringValue}'
and ACTIVE_TIMESTAMP>='{Root Container.Date Range.startDate}'
and ACTIVE_TIMESTAMP<='{Root Container.Date Range.endDate}'
order by ACTIVE_TIMESTAMP desc
But I can’t figure out how to display all of the alarms if “All” is selected in the dropdown menu. Is there a way I can enable/disable the and STATE_NAME=’{Root Container.Dropdown 1.selectedStringValue}’ part of the where clause if “All” is selected? I’m not really an SQL guru so I don’t know if there is an easy way of doing this or not. I’ve tried putting SELECT “All” as Null in on the dropdown box but that didn’t work so now I’m not sure what to do. Any ideas would be much appreciated, thanks!