system.db.runUpdateQuery doesn't work in Script console

Hello Guys,
I have Problem here with the database update using script, when I use same query string in Database Query Browser it's working fine, but using script console getting error.

The insert query used in script console is:

query_01="INSERT INTO predictive_test_data (station_number, line_number, test_ID, test_result_value, test_date_and_time)"
query_02=" VALUES (10,'s000001',21 ,1543 ,'2019.08.20 10:10:34')"
query=query_01 + query_02
system.db.runUpdateQuery(query)

The insert query used in Database Query Browser is:

INSERT INTO predictive_test_data (station_number, line_number, test_ID, test_result_value, test_date_and_time) VALUES (10,'s000001',21 ,1543 ,'2019.08.20 10:10:34')

the Error that I got is:

Java Traceback:
Traceback (most recent call last):
File "", line 14, in
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:362)

at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runUpdateQuery(AbstractDBUtilities.java:183)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

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

java.lang.Exception: java.lang.Exception: Error executing system.db.runUpdateQuery(INSERT INTO predictive_test_data (station_number, line_number, test_ID, test_result_value, test_date_and_time) VALUES (10,'s000001',21 ,1543 ,'2019.08.20 10:10:34'), , , false)

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

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

at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runUpdateQuery(AbstractDBUtilities.java:183)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

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

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

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

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

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

at org.python.pycode._pyx34.f$0(<buffer>:16)

at org.python.pycode._pyx34.call_function(<buffer>)

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

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

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

at org.python.core.Py.exec(Py.java:1658)

at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)

at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:131)

at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:116)

at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$InterpreterWorker.doInBackground(JythonConsole.java:506)

at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$InterpreterWorker.doInBackground(JythonConsole.java:494)

at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)

at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

at java.desktop/javax.swing.SwingWorker.run(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

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

Caused by: java.lang.Exception: Error executing system.db.runUpdateQuery(INSERT INTO predictive_test_data (station_number, line_number, test_ID, test_result_value, test_date_and_time) VALUES (10,'s000001',21 ,1543 ,'2019.08.20 10:10:34'), , , false)

... 27 more

Caused by: com.inductiveautomation.ignition.client.gateway_interface.GatewayException: Cannot run this function when in read-only mode.

at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.getResponse(GatewayInterface.java:374)

at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:273)

at com.inductiveautomation.ignition.client.gateway_interface.GatewayInterface.sendMessage(GatewayInterface.java:268)

at com.inductiveautomation.ignition.client.script.ClientDBUtilities._runUpdateQuery(ClientDBUtilities.java:189)

at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runUpdateQuery(AbstractDBUtilities.java:181)

... 25 more

Traceback (most recent call last):
File "", line 14, in
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:362)

at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runUpdateQuery(AbstractDBUtilities.java:183)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

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

java.lang.Exception: java.lang.Exception: Error executing system.db.runUpdateQuery(INSERT INTO predictive_test_data (station_number, line_number, test_ID, test_result_value, test_date_and_time) VALUES (10,'s000001',21 ,1543 ,'2019.08.20 10:10:34'), , , false)

can you help please!!!
Regards

Set your designer to Read/Write mode.
rw

it is already in Read/Write mode !!!

I found the solution, thanks chi for your hints, there are two Setting of the Designer mode as appeared in my first Reply and one by Project properties as you see here in the attached Picture, so when you Change the mode to read/write in the designer screen it doesn’t affect on the Project properties (initial Gateway comm mode), you Need to Change both to read/write mode, then it works perfectly.

Glad you got it working.
The problem sounds like a bug to me since the project setting should simply be the initial setting for the designer. Maybe the setting in the designer is for any reason not applied to the script console.

1 Like