# Error from SQL DELETE statement -did not return a result set

**URL:** <https://forum.inductiveautomation.com/t/error-from-sql-delete-statement-did-not-return-a-result-set/9891>\
**Category:** Ignition\
**Created:** [April 8, 2015, 4:37pm UTC](https://forum.inductiveautomation.com/t/error-from-sql-delete-statement-did-not-return-a-result-set/9891 "2015-04-08T16:37:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gratliff](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gratliff](https://forum.inductiveautomation.com/u/Gratliff)\
**Post date:** [April 8, 2015, 4:37pm UTC](https://forum.inductiveautomation.com/t/error-from-sql-delete-statement-did-not-return-a-result-set/9891/1 "2015-04-08T16:37:42Z")

</div>

I have a power table that is bound to a db table. Under the table is a button that allows the user to delete a record from the SQL table based on the row selected in the power table. The button runs this script on mouse\>action performed:

[code]# delete the selected record by id  
id = event.source.parent.parent.getComponent(‘Power Table’).selectedID

# make sure the user wants to delete; if yes, run delete query

if id \> 0:  
system.db.runQuery("DELETE FROM Microblend\_EventDefinition\_Confi WHERE ID = " + str(id))  
else:  
system.gui.messageBox(“You must select a row first”)  
[/code]  
When the button is pressed, it deletes the record ok but give the following error (why do I get this error):

[ul]Traceback (most recent call last):  
File “event:actionPerformed”, line 5, in   
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:362)

```
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runQuery(AbstractDBUtilities.java:333)

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)

```

java.lang.Exception: java.lang.Exception: Error executing system.db.runQuery(DELETE FROM Microblend\_EventDefinition\_Confi WHERE ID = 22, , )

```
at org.python.core.Py.JavaError(Py.java:495)
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:362)
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runQuery(AbstractDBUtilities.java:333)
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:186)
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. __call__ (ScriptManager.java:406)
at org.python.core.PyObject. __call__ (PyObject.java:387)
at org.python.core.PyObject. __call__ (PyObject.java:391)
at org.python.pycode._pyx872.f$0(<event:actionPerformed>:7)
at org.python.pycode._pyx872.call_function(<event:actionPerformed>)
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:551)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.runActions(ActionAdapter.java:168)
at com.inductiveautomation.factorypmi.application.binding.action.ActionAdapter.invoke(ActionAdapter.java:265)
at com.inductiveautomation.factorypmi.application.binding.action.RelayInvocationHandler.invoke(RelayInvocationHandler.java:55)
at com.sun.proxy.$Proxy21.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

```

Caused by: java.lang.Exception: Error executing system.db.runQuery(DELETE FROM Microblend\_EventDefinition\_Confi WHERE ID = 22, , )  
… 56 more  
Caused by: com.inductiveautomation.ignition.client.gateway\_interface.GatewayException: The statement did not return a result set.  
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.newGatewayException(GatewayInterface.java:321)  
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.sendMessage(GatewayInterface.java:295)  
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.sendMessage(GatewayInterface.java:252)  
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.runLimitQuery(GatewayInterface.java:727)  
at com.inductiveautomation.ignition.client.gateway\_interface.GatewayInterface.runQuery(GatewayInterface.java:686)  
at com.inductiveautomation.ignition.client.script.ClientDBUtilities.\_runQuery(ClientDBUtilities.java:164)  
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runQuery(AbstractDBUtilities.java:329)  
… 54 more  
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.  
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170)  
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:794)  
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:685)  
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4026)  
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1416)  
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:185)  
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:160)  
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeQuery(SQLServerStatement.java:620)  
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:208)  
at com.inductiveautomation.ignition.gateway.datasource.DelegatingStatement.executeQuery(DelegatingStatement.java:63)  
at com.inductiveautomation.ignition.gateway.datasource.SRConnectionWrapper$SRStatement.executeQuery(SRConnectionWrapper.java:708)  
at com.inductiveautomation.ignition.gateway.servlets.gateway.functions.RunQuery.run(RunQuery.java:98)  
at com.inductiveautomation.ignition.gateway.servlets.gateway.functions.AbstractDBAction.invoke(AbstractDBAction.java:76)  
at com.inductiveautomation.ignition.gateway.servlets.Gateway.doPost(Gateway.java:343)  
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)  
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)  
at com.inductiveautomation.ignition.gateway.bootstrap.MapServlet.service(MapServlet.java:85)  
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:696)  
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:526)  
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143)  
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:568)  
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)  
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1110)  
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:453)  
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)  
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1044)  
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)  
at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:52)  
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)  
at org.eclipse.jetty.server.Server.handle(Server.java:459)  
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:280)  
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:229)  
at org.eclipse.jetty.io.AbstractConnection$1.run(AbstractConnection.java:505)  
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:607)  
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:536)  
at java.lang.Thread.run(null)

Ignition v7.7.2 (b2014121709)  
Java: Oracle Corporation 1.8.0\_11[/ul]

---

<div class="post-metadata">

**Author:** ![diat150](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diat150](https://forum.inductiveautomation.com/u/diat150)\
**Post date:** [April 8, 2015, 5:26pm UTC](https://forum.inductiveautomation.com/t/error-from-sql-delete-statement-did-not-return-a-result-set/9891/2 "2015-04-08T17:26:36Z")

</div>

for a delete statement you need to use system.db.runPrepUpdate.

the system.db.runQuery is used for select statements that return a result set. thats what the error is complaining about.

---

<div class="post-metadata">

**Author:** ![Gratliff](https://avatars.discourse-cdn.com/v4/letter/g/a5b964/32.png) [@Gratliff](https://forum.inductiveautomation.com/u/Gratliff)\
**Post date:** [April 8, 2015, 5:34pm UTC](https://forum.inductiveautomation.com/t/error-from-sql-delete-statement-did-not-return-a-result-set/9891/3 "2015-04-08T17:34:11Z")

</div>

Excellent that was it, thanks.
