# Update two columns in a table

**URL:** <https://forum.inductiveautomation.com/t/update-two-columns-in-a-table/33953>\
**Category:** Ignition\
**Created:** [April 15, 2020, 2:19pm UTC](https://forum.inductiveautomation.com/t/update-two-columns-in-a-table/33953 "2020-04-15T14:19:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![twstevic](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@twstevic](https://forum.inductiveautomation.com/u/twstevic)\
**Post date:** [April 15, 2020, 2:19pm UTC](https://forum.inductiveautomation.com/t/update-two-columns-in-a-table/33953/1 "2020-04-15T14:19:58Z")

</div>

I am trying to update a row in a database table using two SQL statements. My script:

```auto
param1 = {"IG_Tag":"SCADA_ALARM_CP01_0_2"}
param2 = {"IG_Index":Idx}

system.db.runNamedQuery("Get_Alarm", param1)
system.db.runNamedQuery("Update_Display", param1, param2)

```

The first Query works fine (sets a bunch of column values in the ‘igeventdisp’ table)  
The second Query is:

```auto
UPDATE igeventdisp 
SET IG_Event_Set_Time = current_timestamp(0), IG_Event_Index = :IG_Index
WHERE IG_PLC_Tag = :IG_Tag;

```

The error is “Transaction “{’,IG\_Index’: 103.0}” is closed.”

I have tried wrapping the first query with:  
system.db.beginTransaction("")  
system.db.closeTransaction("") {with and without system.db.commitTransaction("")}

Each query runs fine when executed by themselves.  
Do any DB people have a clue, (as I am clueless)?

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [April 15, 2020, 2:36pm UTC](https://forum.inductiveautomation.com/t/update-two-columns-in-a-table/33953/2 "2020-04-15T14:36:13Z")

</div>

You will need to combine the parameters for the 2nd runNamedQuery.

**system.db.runNamedQuery(path, parameters, [getKey])**  
**system.db.runNamedQuery(project, path, parameters, [getKey])**

---

<div class="post-metadata">

**Author:** ![twstevic](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@twstevic](https://forum.inductiveautomation.com/u/twstevic)\
**Post date:** [April 15, 2020, 2:57pm UTC](https://forum.inductiveautomation.com/t/update-two-columns-in-a-table/33953/3 "2020-04-15T14:57:23Z")

</div>

I added :

```auto
params = [param1, param2]
system.db.runNamedQuery("Update_Display", params)

```

Now my error is:  
Cannot coerce value ‘[{‘IG\_Tag’: ‘SCADA\_ALARM\_CP01\_0\_2’}, {‘IG\_Index’: 103.0}]’ into type: interface java.util.Map

---

<div class="post-metadata">

**Author:** ![jonathan.taylor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jonathan.taylor/32/4048_2.png) [@jonathan.taylor](https://forum.inductiveautomation.com/u/jonathan.taylor)\
**Post date:** [April 15, 2020, 3:09pm UTC](https://forum.inductiveautomation.com/t/update-two-columns-in-a-table/33953/4 "2020-04-15T15:09:20Z")

</div>

Parameters need to be within one set of curly braces, as key pairs.The second named query needs two parameters, you would pass something like the following (note the comma separating each key pair):

```auto
params = {"IG_Tag":"SCADA_ALARM_CP01_0_2" , "IG_Index":Idx }

```

---

<div class="post-metadata">

**Author:** ![twstevic](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@twstevic](https://forum.inductiveautomation.com/u/twstevic)\
**Post date:** [April 15, 2020, 3:26pm UTC](https://forum.inductiveautomation.com/t/update-two-columns-in-a-table/33953/5 "2020-04-15T15:26:35Z")

</div>

EXCELLENT!!!  
Thank you so much.
