# \[IGN-13835\] Scalar named query with system.db.execQuery fails

**URL:** <https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377>\
**Category:** Ignition 8.3 Early Access\
**Created:** [August 5, 2025, 12:31pm UTC](https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377 "2025-08-05T12:31:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![automatisation](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@automatisation](https://forum.inductiveautomation.com/u/automatisation)\
**Post date:** [August 5, 2025, 12:31pm UTC](https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377/1 "2025-08-05T12:31:28Z")

</div>

Hi,  
The new call for executing scalar named queries fails when executing.  
Example of simple named query

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/7/07cb67414f663f5b4d84afc1736de900cdecf496.png)  
A call with system.db.runNamedQuery works  
A call with system.db.execQuery fails with the following error :

```python
Java Traceback:
Traceback (most recent call last):
  File "<input>", line 1, in <module>
	at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.execQuery(AbstractDBUtilities.java:688)

	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

	at java.base/java.lang.reflect.Method.invoke(Unknown Source)

java.lang.ClassCastException: java.lang.ClassCastException: class java.sql.Timestamp cannot be cast to class com.inductiveautomation.ignition.common.Dataset (java.sql.Timestamp is in module java.sql of loader 'platform'; com.inductiveautomation.ignition.common.Dataset is in unnamed module of loader java.net.URLClassLoader @44ea2863)

	at org.python.core.Py.JavaError(Py.java:545)

	at org.python.core.Py.JavaError(Py.java:536)

	at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:192)

	at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. __call__ (ScriptManager.java:563)

	at org.python.core.PyObject. __call__ (PyObject.java:461)

	at org.python.core.PyObject. __call__ (PyObject.java:465)

	at org.python.pycode._pyx314.f$0(<input>:1)

	at org.python.pycode._pyx314.call_function(<input>)

	at org.python.core.PyTableCode.call(PyTableCode.java:173)

	at org.python.core.PyCode.call(PyCode.java:18)

	at org.python.core.Py.runCode(Py.java:1703)

	at org.python.core.Py.exec(Py.java:1747)

	at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:277)

	at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:130)

	at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:628)

	at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:616)

	at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)

	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)

	at java.desktop/javax.swing.SwingWorker.run(Unknown Source)

	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

	at java.base/java.lang.Thread.run(Unknown Source)

Caused by: java.lang.ClassCastException: class java.sql.Timestamp cannot be cast to class com.inductiveautomation.ignition.common.Dataset (java.sql.Timestamp is in module java.sql of loader 'platform'; com.inductiveautomation.ignition.common.Dataset is in unnamed module of loader java.net.URLClassLoader @44ea2863)

	at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.execQuery(AbstractDBUtilities.java:688)

	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

	at java.base/java.lang.reflect.Method.invoke(Unknown Source)

	at org.python.core.PyReflectedFunction. __call__ (PyReflectedFunction.java:190)

	... 19 more

Traceback (most recent call last):
  File "<input>", line 1, in <module>
	at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.execQuery(AbstractDBUtilities.java:688)

	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

	at java.base/java.lang.reflect.Method.invoke(Unknown Source)

java.lang.ClassCastException: java.lang.ClassCastException: class java.sql.Timestamp cannot be cast to class com.inductiveautomation.ignition.common.Dataset (java.sql.Timestamp is in module java.sql of loader 'platform'; com.inductiveautomation.ignition.common.Dataset is in unnamed module of loader java.net.URLClassLoader @44ea2863)

```

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [August 5, 2025, 12:59pm UTC](https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377/2 "2025-08-05T12:59:02Z")

</div>

> [@automatisation](#):
>
> system.db.execQuery

~~What is this? This isn't a documented function. [system.db | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-db)~~

Whats wrong with using system.db.runNamedQuery? You're defining a named query and that's what I would expect to call it.

~~Always helps if you can share your script too.~~

Did not see version. My fault.

Not for nothing either but if you just want the current time `system.date.now()` is available to you unless you specifically want the databases time.

---

<div class="post-metadata">

**Author:** ![automatisation](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@automatisation](https://forum.inductiveautomation.com/u/automatisation)\
**Post date:** [August 5, 2025, 1:14pm UTC](https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377/3 "2025-08-05T13:14:18Z")

</div>

This concerns Ignition 8.3, where system.db.runNamedQuery is deprecated

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/2/026bcf34de941f1df0e3cea416348a75333dd406.png)  
I tagged the topic with the 8.3 category.

The query returning the current datetime was just an example. No use in giving my specific scalar query as no one would be able to reproduce it without our database structure.

---

<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:** [August 5, 2025, 1:19pm UTC](https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377/4 "2025-08-05T13:19:15Z")

</div>

Considering that execQuery and execUpdate are distinct, there's probably going to be an execScalar or similar. It just isn't documented yet.

---

<div class="post-metadata">

**Author:** ![automatisation](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@automatisation](https://forum.inductiveautomation.com/u/automatisation)\
**Post date:** [August 5, 2025, 1:28pm UTC](https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377/5 "2025-08-05T13:28:44Z")

</div>

Maybe.  
That would change from 8.1 where "normal" and scalar named queries were handled by the same function.  
And documentation would need to be changed [system.db.execQuery | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.3/appendix/scripting-functions/system-db/system-db-execQuery#returns)

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [August 5, 2025, 2:43pm UTC](https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377/6 "2025-08-05T14:43:43Z")

</div>

It would be in line with the old system.db.runQuery vs runUpdateQuery vs runScalarQuery (and their prep equivalents) though I get that runNamedQuery was a catch all for all 3. I guess its a return to the old form.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 5, 2025, 4:25pm UTC](https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377/7 "2025-08-05T16:25:54Z")

</div>

As currently implemented, `execQuery` is supposed to be used for scalar results and that it doesn't is a bug -- thanks @automatisation for the report.

But I think I've convinced myself that I actually _do_ want to add a distinct `execScalar` function, to give you a sort of "type safety" where you have to assert that you know what kind of query you're about to execute even before you execute it. You're basically never going to do the 'right' thing with a result if you were expecting a scalar/dataset/result count but you got something else, so it seems fine to me outside of _maybe_ a contrived use case where you're trying to make a decorator around 'any type of named query'...but again, what would you have been doing with the results from that before?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [August 5, 2025, 4:36pm UTC](https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377/8 "2025-08-05T16:36:17Z")

</div>

Since we cannot do

```python
Dataset ds = system.db.execQuery("SomeQ")
int i = system.db.execQuery("ScalarQuery")

```

I personally am in favor of the more descriptive naming so if I see `execScalar` in code I know I would expect on value there to be a single thing. Otherwise I am having to go look at the SQL.

---

<div class="post-metadata">

**Author:** ![automatisation](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@automatisation](https://forum.inductiveautomation.com/u/automatisation)\
**Post date:** [August 5, 2025, 5:07pm UTC](https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377/9 "2025-08-05T17:07:06Z")

</div>

Distinct functions or additional parameter, as long as it works, I'm happy.  
I'm using the deprecated function call at the moment and it works, so all good.  
I'll check again if a new 8.3 version ships in the future.  
Thanks

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 5, 2025, 5:47pm UTC](https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377/10 "2025-08-05T17:47:21Z")

</div>

Yeah, in case this wasn't clear, while we reserve the right to deprecate scripting functions (and there is a larger than usual set of deprecated functions in 8.3) we essentially never **remove** any functionality - so the old function calls will absolutely continue to work indefinitely. There's no urgent need to migrate them just because you're on 8.3.

---

<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:** [August 5, 2025, 9:27pm UTC](https://forum.inductiveautomation.com/t/ign-13835-scalar-named-query-with-system-db-execquery-fails/109377/11 "2025-08-05T21:27:43Z")

</div>

> [@paul-griffith](#):
>
> we essentially never **remove** any functionality

"Essentially never" means we are finally removing the `alert` scripting functions that were already deprecated when I joined IA in 2013.
