# Named queries exception

**URL:** <https://forum.inductiveautomation.com/t/named-queries-exception/113492>\
**Category:** Ignition\
**Created:** [January 22, 2026, 7:10pm UTC](https://forum.inductiveautomation.com/t/named-queries-exception/113492 "2026-01-22T19:10:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbooth](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jbooth](https://forum.inductiveautomation.com/u/jbooth)\
**Post date:** [January 22, 2026, 7:10pm UTC](https://forum.inductiveautomation.com/t/named-queries-exception/113492/1 "2026-01-22T19:10:39Z")

</div>

Attempting to set up a named query to insert a row if matching one isn’t found, and update part quantity once matching row is in the table. Running the query in database browser works, but when I place the query in a named query and add parameters, i am getting java.lang.ArrayIndexOutOfBoundsException. All columns in this test database are INTEGER, and tried all of the Int# data types for parameter.

Query:

INSERT INTO testDB (style, color, qty)  
SELECT :nStyle, :nColor, 0  
WHERE NOT EXISTS (  
SELECT 1  
FROM testDB  
WHERE style = :nStyle AND color = :nColor  
);  
UPDATE testDB  
SET qty = qty + :nQty  
WHERE style = :nStyle AND color = :nColor

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [January 22, 2026, 7:14pm UTC](https://forum.inductiveautomation.com/t/named-queries-exception/113492/2 "2026-01-22T19:14:39Z")

</div>

Is the named query marked as an update query? Also, I don't believe that the named queries can handle the return from multiple update statements in the same query.

---

<div class="post-metadata">

**Author:** ![tgarrison](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tgarrison/32/80965_2.png) [@tgarrison](https://forum.inductiveautomation.com/u/tgarrison)\
**Post date:** [January 22, 2026, 7:14pm UTC](https://forum.inductiveautomation.com/t/named-queries-exception/113492/3 "2026-01-22T19:14:40Z")

</div>

Try without the Update.. I'm thinking you can't do multiple statements in one named query.

---

<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:** [January 22, 2026, 7:54pm UTC](https://forum.inductiveautomation.com/t/named-queries-exception/113492/4 "2026-01-22T19:54:44Z")

</div>

> [@jbooth](#):
>
> SELECT :nStyle, :nColor, 0

This is ok as long as you are expecting the parameters you pass in to be the results in your dataset, but if you’re trying to dynamically use column names these have to query strings just fyi.

---

<div class="post-metadata">

**Author:** ![jbooth](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jbooth](https://forum.inductiveautomation.com/u/jbooth)\
**Post date:** [January 22, 2026, 8:42pm UTC](https://forum.inductiveautomation.com/t/named-queries-exception/113492/5 "2026-01-22T20:42:15Z")

</div>

it is set as an update query. Removing the update portion and running test execution, get error: query does not return results.

The parameters that pass in are values from OPC tags, not dynamic column names. When they select style 1, color 1, with qty 2 on the skid, and press go, i want to look in db for style 1 color 2 and add qty 2. If no row with style 1 color 1, create one and set qty to 2.

---

<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:** [January 22, 2026, 8:56pm UTC](https://forum.inductiveautomation.com/t/named-queries-exception/113492/6 "2026-01-22T20:56:15Z")

</div>

You are trying to use SQL scripts in JDBC. While partially supported by some drivers, SQL scripts are **not** officially supported. Use separate statements in separate named queries.
