# Can't execute multiple runNamedQuery updates

**URL:** <https://forum.inductiveautomation.com/t/cant-execute-multiple-runnamedquery-updates/40555>\
**Category:** Ignition\
**Created:** [November 11, 2020, 7:10pm UTC](https://forum.inductiveautomation.com/t/cant-execute-multiple-runnamedquery-updates/40555 "2020-11-11T19:10:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joe.metz](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@joe.metz](https://forum.inductiveautomation.com/u/joe.metz)\
**Post date:** [November 11, 2020, 7:10pm UTC](https://forum.inductiveautomation.com/t/cant-execute-multiple-runnamedquery-updates/40555/1 "2020-11-11T19:10:50Z")

</div>

I run a script for a button input in Perspective. I want to update two tables in a database. I run system.db.runNamedQuery(query, params) which works followed by system.db.runNamedQuery(query2, params2) which doesn’t work. If I run query2 first system.db.runNamedQuery(query2, params2) it works followed by system.db.runNamedQuery(query, params) which doesn’t work. What’s going on?

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [November 12, 2020, 3:28pm UTC](https://forum.inductiveautomation.com/t/cant-execute-multiple-runnamedquery-updates/40555/2 "2020-11-12T15:28:03Z")

</div>

This obviously isn’t expected behavior. Is there anything in the logs? Have you wrapped it in a try-except block to see if any exceptions are thrown?

---

<div class="post-metadata">

**Author:** ![joe.metz](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@joe.metz](https://forum.inductiveautomation.com/u/joe.metz)\
**Post date:** [November 12, 2020, 3:45pm UTC](https://forum.inductiveautomation.com/t/cant-execute-multiple-runnamedquery-updates/40555/3 "2020-11-12T15:45:11Z")

</div>

Kathy,

I was able to work around the problem by adding multiple scripts. Each script has it’s own runNamedQuery which now works fine and updates a record in each table after pushing the button.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [November 12, 2020, 7:21pm UTC](https://forum.inductiveautomation.com/t/cant-execute-multiple-runnamedquery-updates/40555/4 "2020-11-12T19:21:42Z")

</div>

I encountered something similar a long time ago and had to incorporate [system.db.beginNamedQueryTransaction](https://docs.inductiveautomation.com/display/DOC80/system.db.beginNamedQueryTransaction) along with [system.db.commitTransaction](https://docs.inductiveautomation.com/display/DOC80/system.db.commitTransaction). Once I did that the Script which had multiple Named Queries worked correctly.

It seems like a Named Query commits when a Script Action completes, but not before. If you ned to run multiple named queries, you need to either run them in one batch or commit the previous batch.

---

<div class="post-metadata">

**Author:** ![KathyApplebaum](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kathyapplebaum/32/7261_2.png) [@KathyApplebaum](https://forum.inductiveautomation.com/u/KathyApplebaum)\
**Post date:** [November 13, 2020, 6:58pm UTC](https://forum.inductiveautomation.com/t/cant-execute-multiple-runnamedquery-updates/40555/5 "2020-11-13T18:58:34Z")

</div>

> [@cmallonee](#):
>
> It seems like a Named Query commits when a Script Action completes, but not before.

Definitely not intended behavior outside of transactions. Sounds like a bug to me.

---

<div class="post-metadata">

**Author:** ![Tim.Johnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tim.johnson/32/10597_2.png) [@Tim.Johnson](https://forum.inductiveautomation.com/u/Tim.Johnson)\
**Post date:** [March 12, 2021, 12:05am UTC](https://forum.inductiveautomation.com/t/cant-execute-multiple-runnamedquery-updates/40555/6 "2021-03-12T00:05:27Z")

</div>

@KathyApplebaum, was this captured as a bug? I’m still seeing this behavior in 8.1.2.

Thanks @cmallonee for the workaround!

---

<div class="post-metadata">

**Author:** ![antonmarthedal](https://avatars.discourse-cdn.com/v4/letter/a/8edcca/32.png) [@antonmarthedal](https://forum.inductiveautomation.com/u/antonmarthedal)\
**Post date:** [April 24, 2025, 12:02pm UTC](https://forum.inductiveautomation.com/t/cant-execute-multiple-runnamedquery-updates/40555/7 "2025-04-24T12:02:00Z")

</div>

Have the bug been solved?
