# RunNamedQuery from Project Script Error

**URL:** <https://forum.inductiveautomation.com/t/runnamedquery-from-project-script-error/28965>\
**Category:** Ignition\
**Created:** [October 9, 2019, 6:19pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-from-project-script-error/28965 "2019-10-09T18:19:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [October 9, 2019, 6:19pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-from-project-script-error/28965/1 "2019-10-09T18:19:59Z")

</div>

Why when I run a named query in a project script I receive this?

I am running

> system.db.runNamedQuery("MyProject", "MyQueries/NamedQuery", {"parameter":"myParameter"}, 0)

and I get this error

```auto
java.lang.Exception: java.sql.SQLException: Transaction "0" is closed.

```

When I run the same line of code on a button in a perspective view it works fine.

---

<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:** [October 9, 2019, 7:13pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-from-project-script-error/28965/2 "2019-10-09T19:13:09Z")

</div>

What version are you using? The docs have not had time to catch up yet, but newer versions of Ignition (\>=8.0.4) actually introduced transactional queries, so the `0` is being interpreted as the `tx` argument.

![33%20PM](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/73c92c2a22bd9cd3a50ab5029319a84eb9d02072.png)

You have several options available to you, but what I recommend is simply modifying your code to:

```auto
system.db.runNamedQuery(“MyProject”, “MyQueries/NamedQuery”, {“parameter”:“myParameter”}, getKey=0)

```

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [October 9, 2019, 8:58pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-from-project-script-error/28965/3 "2019-10-09T20:58:40Z")

</div>

That is it. We are currently running 8.0.4. The manual does not say anything about “tx”, but if I do a ctrl+spacebar I see the tx parameter. Long story short always send named parameters and then you do not have to rely on the positioning to be correct.

---

<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:** [October 9, 2019, 9:24pm UTC](https://forum.inductiveautomation.com/t/runnamedquery-from-project-script-error/28965/4 "2019-10-09T21:24:12Z")

</div>

This is a pretty good practice yes, as it also helps for long-term maintenance.
