# Named query: SELECT works but UPDATE doesn't

**URL:** <https://forum.inductiveautomation.com/t/named-query-select-works-but-update-doesnt/24994>\
**Category:** Ignition\
**Created:** [May 14, 2019, 6:03pm UTC](https://forum.inductiveautomation.com/t/named-query-select-works-but-update-doesnt/24994 "2019-05-14T18:03:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 14, 2019, 6:03pm UTC](https://forum.inductiveautomation.com/t/named-query-select-works-but-update-doesnt/24994/1 "2019-05-14T18:03:55Z")

</div>

I have two named queries set up in Ignition for MariaDB:

```auto
Query type: Query
SELECT * FROM devices

```

This works.

```auto
Query type: Update Query
UPDATE devices
SET description = 'Beautiful'
WHERE id = 9

```

This works in phpMyAdmin front end running on the Ignition server PC but testing with the Named Queries editor results in

> ava.sql.SQLException: Could not set parameter at position 1 (values was 'description') Query - conn:771(M) - "

Any ideas?

---

<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:** [May 14, 2019, 6:16pm UTC](https://forum.inductiveautomation.com/t/named-query-select-works-but-update-doesnt/24994/2 "2019-05-14T18:16:42Z")

</div>

Is the Named Query literally just that provided String, or is it something like

```auto
UPDATE devices SET "{col}" = ':val' WHERE id = :id

```

Quick online search would suggest removing the double quotes around `":col"`. If your Named Query is just a query which has no parameters configured/expected/received, then something else is going on.

---

<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:** [May 14, 2019, 6:36pm UTC](https://forum.inductiveautomation.com/t/named-query-select-works-but-update-doesnt/24994/3 "2019-05-14T18:36:08Z")

</div>

> [@cmallonee](#):
>
> Quick online search would suggest removing the double quotes around `":col"` . If your Named Query is just a query which has no parameters configured/expected/received, then something else is going on.

JDBC (or other interfaces for any DB I know) does not permit parameterizing query structure, just values. Column names are structure. So `":col"` would in the above would never be acceptable, with or without the double quotes. Parameterized values are not quoted, so ':val' will not work either.

---

<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:** [May 14, 2019, 7:25pm UTC](https://forum.inductiveautomation.com/t/named-query-select-works-but-update-doesnt/24994/4 "2019-05-14T19:25:29Z")

</div>

I might be misunderstanding the original question (and I _definitely_ had the syntax wrong - yikes), but with Named Queries, you can specify a QueryString Type and provide a query like

```auto
SELECT beverages.{col} as data from beverages where id=1

```

where `col` is passed in as a String.

But if it was

```auto
beverages."{col}"

```

then there would be an issue.

---

<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:** [May 14, 2019, 7:36pm UTC](https://forum.inductiveautomation.com/t/named-query-select-works-but-update-doesnt/24994/5 "2019-05-14T19:36:32Z")

</div>

Huh. If you are going to allow structure substitutions, you really should allow the double-quoted form – that’s the SQL standard for identifier quoting. FWIW, it seems to defeat the whole purpose of Named Queries.

---

<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:** [May 14, 2019, 8:07pm UTC](https://forum.inductiveautomation.com/t/named-query-select-works-but-update-doesnt/24994/6 "2019-05-14T20:07:13Z")

</div>

> [@pturmel](#):
>
> FWIW, it seems to defeat the whole purpose of Named Queries.

Query Strings fall under the category of "a tool we give you that we highly discourage using" 😆

---

<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:** [May 14, 2019, 8:09pm UTC](https://forum.inductiveautomation.com/t/named-query-select-works-but-update-doesnt/24994/7 "2019-05-14T20:09:45Z")

</div>

@Transistor: Could you post a screenshot of the NamedQuery from the Designer so that we can rule out formatting?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 15, 2019, 3:16pm UTC](https://forum.inductiveautomation.com/t/named-query-select-works-but-update-doesnt/24994/8 "2019-05-15T15:16:38Z")

</div>

Thanks, all. I left this overnight and when I returned in the morning it worked! I’m running on a trial licence on a development machine. The query works from the Named Query test window whether the 2-hour trial has expired or not. This has me rather puzzled.

The test query in my original post is the literal SQL query. Screen grab below.

 ![Ignition%20queryDevicesUpdate](https://us1.discourse-cdn.com/inductiveautomation/original/2X/c/cd4a85347817e67d13ff5b32a6b2b1b3da673f5d.png)

Now I’m wondering if I somehow upset the MariaDB / mySQL privileges while debugging this. I’ll do some more research and testing.
