Gateway event script running a named update query

Hi Guys,

I can’t get a timer (every 5 seconds) gateway event script that runs a named update query to work.

If I run the same code on a button it works as expected…

Any assistance would be appreciated.

Named Query:

INSERT INTO test (id) VALUES (:id)

Timer Gateway Event Script:

id = “test”
params = {“id”:id}
system.db.runNamedQuery(“test”, params)

Error:

Traceback (most recent call last): File “<TimerScript:Weather/test @5,000ms >”, line 3, in <module> at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:354) at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) java.lang.NullPointerException: java.lang.NullPointerException

com.inductiveautomation.ignition.common.script.JythonExecException: Traceback (most recent call last): File “”, line 3, in at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:354) at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) java.lang.NullPointerException: java.lang.NullPointerException

at org.python.core.Py.JavaError(Py.java:495)

at org.python.core.Py.JavaError(Py.java:488)

at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:188)

at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction.call(ScriptManager.java:431)

at org.python.core.PyObject.call(PyObject.java:404)

at org.python.core.PyObject.call(PyObject.java:408)

at org.python.pycode._pyx17.f$0(:3)

at org.python.pycode._pyx17.call_function()

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

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

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

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

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

at com.inductiveautomation.ignition.common.script.TimerScriptTask.run(TimerScriptTask.java:88)

at java.util.TimerThread.mainLoop(Unknown Source)

at java.util.TimerThread.run(Unknown Source)

Caused by: org.python.core.PyException: Traceback (most recent call last): File “”, line 3, in at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:354) at sun.reflect.GeneratedMethodAccessor95.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) java.lang.NullPointerException: java.lang.NullPointerException

… 16 common frames omitted

Caused by: java.lang.NullPointerException: null

at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.runNamedQuery(GatewayDBUtilities.java:354)

at sun.reflect.GeneratedMethodAccessor95.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:186)

As soon as I post I figure it out…

Needed to change:

system.db.runNamedQuery(“test”, params)

To:

system.db.runNamedQuery(“Project Name”, “test”, params)

2 Likes