Event Script (Client) Error

Hello,

My post has 2 questions:

[size=150]1)[/size] I am running a tag change script on the Client:

[code]from java.util import Date
dateFrom = Date()
dateTo = Date()

dateFrom.setSeconds(dateFrom.getSeconds()-2)
dateFrom = system.db.dateFormat(dateFrom,“yyyy-MM-dd HH:mm:ss”)
dateTo.setSeconds(dateTo.getSeconds()+2)
dateTo = system.db.dateFormat(dateTo,“yyyy-MM-dd HH:mm:ss”)

value = newValue.value
pathString = event.tagPath
username = system.tag.getTagValue("[]Line01/currentPLCUser")

#print “UPDATE alarms SET ACK_USER = ‘%s’ WHERE (ACK_TIMESTAMP BETWEEN ‘%s’ AND ‘%s’) AND PATH LIKE ‘%s’” % (username, dateFrom, dateTo, pathString)
if value == 0:
system.db.runPrepUpdate(“UPDATE alarms SET ACK_USER = ? WHERE (ACK_TIMESTAMP BETWEEN ? AND ?) AND PATH LIKE ?”, [username, dateFrom, dateTo, pathString ])[/code]

and i get the following error:

[code]ERROR [TagChangeScriptManager-TagChangeScript: Line01/SGM/Alarms/RTD/spreader_box_left_rtd] Error executing tag change script: Line01/SGM/Alarms/RTD/spreader_box_left_rtd
Traceback (innermost last):
File “TagChangeScript:Line01/SGM/Alarms/RTD/spreader_box_left_rtd”, line 16, in ?
java.lang.Exception: Error executing system.db.runPrepUpdate(UPDATE alarms SET ACK_USER = ? WHERE (ACK_TIMESTAMP BETWEEN ? AND ?) AND PATH LIKE ?, [admin, 2011-03-16 13:57:44, 2011-03-16 13:57:48, Line01/SGM/Alarms/RTD/spreader_box_left_rtd], , , false)

at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:293)

at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runPrepUpdate(AbstractDBUtilities.java:218)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)

at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:310)

at org.python.core.PyObject.__call__(PyObject.java)

at org.python.core.PyObject.invoke(PyObject.java)

at org.python.pycode._pyx91.f$0(<TagChangeScript:Line01/SGM/Alarms/RTD/spreader_box_left_rtd>:16)

at org.python.pycode._pyx91.call_function(<TagChangeScript:Line01/SGM/Alarms/RTD/spreader_box_left_rtd>)

at org.python.core.PyTableCode.call(PyTableCode.java)

at org.python.core.PyCode.call(PyCode.java)

at org.python.core.Py.runCode(Py.java)

at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:391)

at com.inductiveautomation.ignition.common.script.TagChangeScriptManager$TagChangeScriptHandler$Runner.run(TagChangeScriptManager.java:138)

at java.lang.Thread.run(Unknown Source)

Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Gateway Error 202: Error executing prepared statement. Unknown class ‘SimplifiedTagPath’ at argument 3

at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(GatewayInterface.java:279)

at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.newGatewayException(GatewayInterface.java:275)

at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.runPrepStmt(GatewayInterface.java:456)

at com.inductiveautomation.ignition.client.script.ClientDBUtilities._runPrepStmt(ClientDBUtilities.java:71)

at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runPrepUpdate(AbstractDBUtilities.java:216)

... 16 more

java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepUpdate(UPDATE alarms SET ACK_USER = ? WHERE (ACK_TIMESTAMP BETWEEN ? AND ?) AND PATH LIKE ?, [admin, 2011-03-16 13:57:44, 2011-03-16 13:57:48, Line01/SGM/Alarms/RTD/spreader_box_left_rtd], , , false)

at org.python.core.Py.JavaError(Py.java)
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:293)
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runPrepUpdate(AbstractDBUtilities.java:218)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.__call__(ScriptManager.java:310)
at org.python.core.PyObject.__call__(PyObject.java)
at org.python.core.PyObject.invoke(PyObject.java)
at org.python.pycode._pyx91.f$0(<TagChangeScript:Line01/SGM/Alarms/RTD/spreader_box_left_rtd>:16)
at org.python.pycode._pyx91.call_function(<TagChangeScript:Line01/SGM/Alarms/RTD/spreader_box_left_rtd>)
at org.python.core.PyTableCode.call(PyTableCode.java)
at org.python.core.PyCode.call(PyCode.java)
at org.python.core.Py.runCode(Py.java)
at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:391)
at com.inductiveautomation.ignition.common.script.TagChangeScriptManager$TagChangeScriptHandler$Runner.run(TagChangeScriptManager.java:138)
at java.lang.Thread.run(Unknown Source)

[/code]

Any ideas why? the SQL statement that i print is correct because i ran it in the MySQL db

[size=150]2)[/size] Why can’t i use this script in the Event Scripts (Gateway)? It seems it never runs, but in Client works fine:

Hi,

For the error, it looks like it’s sending an actual tagpath object that only exists in the client to the gateway, instead of the string. Try this:

if value == 0: system.db.runPrepUpdate("UPDATE alarms SET ACK_USER = ? WHERE (ACK_TIMESTAMP BETWEEN ? AND ?) AND PATH LIKE ?", [username, dateFrom, dateTo, str(pathString) ])
(It’s the same as yours, with ‘pathString’ wrapped in a string cast)

For #2, not sure- it should work. Try adding a print statement, and then look for it in the gateway console. And of course, these scripts only take hold when the project is saved.

Regards,