Run Script Poll Rate


I have a run script in an expression for a SQL tag which seems to be executing at the scan class rate even though I have the poll rate set at 10 seconds. Is this what should happen or is there any way to prevent it from executing at the scan class rate. Attached is the trace history of select statements and the code I have running in the script.

runScript("system.db.runScalarQuery(\"SELECT State_Description FROM Machines_States WHERE Machine_ID = 3 AND State_ID = 20\",'PMON')",10000)


I have the same issue running a global script on a template which is the same select statement. I thought that it would run just once when the if condition was true but is running all the time. What I am doing on the template is querying what the state of a machine is when the PLC state is greater than 19 i.e. faulted state. I thought by using 0 it would behave like the now function. I tried putitng the poll rate at 10000 but it still runs all the time

"<html><b><div align center>"+ {Coater.DataType::Machine_Name}+ "<br>"+{Coater.Multi-State Indicator.text} +" "+{Coater.DataType::LastChange.LastChangeTime} +"<br>"+ if({Coater.DataType::State} > 19 ,runScript("app.MachineState.MC_State("+{Coater.DataType::Machine_ID}+","+{Coater.DataType::State}+")",0),"")
Script Code

def MC_State(Machine_ID,State_ID): import system strMC_ID = str(Machine_ID) strST_ID = str(State_ID) Data = system.db.runQuery("SELECT State_Description FROM Machines_States WHERE Machine_ID = " + strMC_ID + " AND State_ID = " + strST_ID) rowData = Data[0] State = rowData['State_Description'] return State


Wondering if there is a solution to the run script poll rate or is there some other work around I could employ to stop the script from executing all the time


Hi Aidan,

Did you try using a different scan class for the tag?