Community

Question: How to retrieve the latest alarm text as a string when a new alarm occurs?

09.01.2026 12:01 by Snehaal Kapadia

Hi everyone,

We are working on a customer requirement where we need to retrieve the latest alarm text as a string whenever a new alarm occurs.

Currently, we are stuck at querying the latest alarm. We have written a query to fetch the most recent alarm text, but it is failing in the CTRL script with an error.

main()
{

//SELECT '_alert_hdl.._text' FROM '*' LAST 1
//SELECT ALERT '_alert_hdl.._text' FROM '*' LAST 1
string query = "SELECT ALERT '_alert_hdl.._text' FROM '*' LAST 1";
dpQueryConnectAll("_AlarmCallback", TRUE, 0, query);
}

void _AlarmCallback(anytype userData, dyn_dyn_anytype res)
{
if (dynlen(res) < 2)
{
return;
}

for (int i = 2; i <= dynlen(res); i++)
{
string dpName = res[i][1];
string state = res[i][2];

// if (state != "CAME")
// continue;

string alarmText;
dpGet(dpName + "._alert_hdl._text", alarmText);

if (alarmText != "")
{
DebugN("Alarm Text"+ alarmText);
}
}
}


Error is following
WCCOActrl (2), 2026.01.09 16:14:45.255, PARAM,SEVERE, 81, Syntax error, Query not successful: dpQueryConnectAll(SELECT ALERT...) not allowed

Any help or guidance would be greatly appreciated.

Thanks in advance.
Dhaval Abotiyawala

Responses (0)

Log in to write a response to this question.
Back to list