# Named Query Gateway Context

**URL:** <https://forum.inductiveautomation.com/t/named-query-gateway-context/22415>\
**Category:** Ignition\
**Created:** [February 7, 2019, 2:31pm UTC](https://forum.inductiveautomation.com/t/named-query-gateway-context/22415 "2019-02-07T14:31:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [February 7, 2019, 2:31pm UTC](https://forum.inductiveautomation.com/t/named-query-gateway-context/22415/1 "2019-02-07T14:31:06Z")

</div>

Are there any planned updates to the system.db.runNamedQuery() function?

The fact that the code is required to be different in the Client/Designer context vs. the Gateway context is super frustrating as we commonly code in shared or project scripts and these are debugged in the designer, but later executed in the gateway. I understand the need to specify the Project in the gateway context, but can the function be a bit more intelligent and first check the project the script is executing from?

`data = system.db.runNamedQuery(system.util.getProjectName(), 'getItemData')`

Or, can this function accepted keyword parameters and when called in the Client or Designer context, just ignore the project parameter? Just trying to find ways to make this easier without writing more lines of code for every query just to detect what context I am in.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 7, 2019, 2:56pm UTC](https://forum.inductiveautomation.com/t/named-query-gateway-context/22415/2 "2019-02-07T14:56:19Z")

</div>

> [@ryanjmclaughlin](#):
>
> Or, can this function accepted keyword parameters and when called in the Client or Designer context, just ignore the project parameter?

The implementation in 8.0 works this way now, by chance.

edit: also, if you left out the project param on the gateway call, it would find the appropriate project if there were one.

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [February 7, 2019, 3:11pm UTC](https://forum.inductiveautomation.com/t/named-query-gateway-context/22415/3 "2019-02-07T15:11:00Z")

</div>

> [@Kevin.Herron](#):
>
> The implementation in 8.0 works this way now, by chance.

Well thats good news!

> [@Kevin.Herron](#):
>
> edit: also, if you left out the project param on the gateway call, it would find the appropriate project if there were one.

I wish this were true, when running a timer script I get NPE without manually adding the project name...

```auto
Traceback (most recent call last):
  File "<TimerScript:***/interfaceProductData @14,400,000ms >", line 2, in <module>
  File "<module:project.oracle>", line 13, in load
java.lang.NullPointerException

java.lang.NullPointerException: java.lang.NullPointerException

7.9.9 (b2018081621)
Oracle Corporation 1.8.0_191

```

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 7, 2019, 3:21pm UTC](https://forum.inductiveautomation.com/t/named-query-gateway-context/22415/4 "2019-02-07T15:21:17Z")

</div>

Sorry, that only applies to 8.

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [February 7, 2019, 5:22pm UTC](https://forum.inductiveautomation.com/t/named-query-gateway-context/22415/5 "2019-02-07T17:22:51Z")

</div>

Ahh… would the below be a bad thing to do in 7.9 as a workaround to keep code clean?

![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/b/b08ca1c0b6f923a5ed79e75c61cb4c60072fe7d1.png)

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [February 7, 2019, 5:26pm UTC](https://forum.inductiveautomation.com/t/named-query-gateway-context/22415/6 "2019-02-07T17:26:22Z")

</div>

Yeah, seems fine to me.
