# Transaction is closed error

**URL:** <https://forum.inductiveautomation.com/t/transaction-is-closed-error/14622>\
**Category:** Ignition\
**Tags:** database, scripting\
**Created:** [June 25, 2017, 8:32pm UTC](https://forum.inductiveautomation.com/t/transaction-is-closed-error/14622 "2017-06-25T20:32:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![qversa](https://avatars.discourse-cdn.com/v4/letter/q/35a633/32.png) [@qversa](https://forum.inductiveautomation.com/u/qversa)\
**Post date:** [June 25, 2017, 8:32pm UTC](https://forum.inductiveautomation.com/t/transaction-is-closed-error/14622/1 "2017-06-25T20:32:37Z")

</div>

Hi, can anybody help me solve this one? I am getting the following ‘Transaction is closed’ error on a pushbutton actionPerformed event:

Here is my script:

==========  
dbConn = “dbName”

table = event.source.parent.getComponent(“Table”)  
data = table.data  
line = data.getValueAt(table.selectedRow,“Row1”)  
charge\_no = data.getValueAt(table.selectedRow,“Row2”)

# if system.gui.confirm(“Are you sure you want to delete the selected record?”): system.db.runPrepUpdate(“DELETE FROM dbTable WHERE line = ? AND charge\_no = ?”, [Row1], [Row2], dbConn) system.db.refresh(event.source.parent.getComponent(‘Table’), “data”) system.gui.messageBox(“Record item deleted”)

Here is the error message:

==========  
Traceback (most recent call last):

File “event:actionPerformed”, line 9, in

java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepUpdate(DELETE FROM dbTable WHERE Row1 = ? AND Row2 = ?, [4], [23], Database, false, false)

caused by Exception: Error executing system.db.runPrepUpdate(DELETE FROM dbTable WHERE line = ? AND charge\_no = ?, [4], [23], dbName, false, false)  
caused by GatewayException: Connection Error: Transaction “dbName” is closed.  
caused by SQLException: Transaction “dbName” is closed.

# Ignition v7.9.3 (b2017060210) Java: Oracle Corporation 1.8.0\_131

Thanks for any assistance.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 25, 2017, 8:51pm UTC](https://forum.inductiveautomation.com/t/transaction-is-closed-error/14622/2 "2017-06-25T20:51:17Z")

</div>

The second parameter to system.db.runPrepUpdate() must be a list of the parameter values to substitute where you’ve placed question marks in the query. You have two parameters, but you’ve placed each value in its own list, messing up the following arguments to runPrepUpdate().  
Replace:

```auto
[Row1], [Row2]

```

with:

```auto
[Row1, Row2]

```

so your values are in a single list. Side note: use triple-backquotes in your posts before and after script snippets to format them correctly. Instead of the lines of equal signs.

---

<div class="post-metadata">

**Author:** ![qversa](https://avatars.discourse-cdn.com/v4/letter/q/35a633/32.png) [@qversa](https://forum.inductiveautomation.com/u/qversa)\
**Post date:** [June 26, 2017, 12:11am UTC](https://forum.inductiveautomation.com/t/transaction-is-closed-error/14622/3 "2017-06-26T00:11:51Z")

</div>

Many thanks, that fixed it!!! I don’t think I would have ever found that.

---

<div class="post-metadata">

**Author:** ![Ryan\_Shaw](https://avatars.discourse-cdn.com/v4/letter/r/dbc845/32.png) [@Ryan\_Shaw](https://forum.inductiveautomation.com/u/Ryan_Shaw)\
**Post date:** [February 8, 2023, 7:03pm UTC](https://forum.inductiveautomation.com/t/transaction-is-closed-error/14622/4 "2023-02-08T19:03:35Z")

</div>

In my case, I had switched from "system.db.runPrepUpdate" to "system.db.runUpdateQuery" and forgot to remove 'args' from my parameters.
