# Exception in update query

**URL:** <https://forum.inductiveautomation.com/t/exception-in-update-query/34481>\
**Category:** Ignition\
**Created:** [May 6, 2020, 1:59pm UTC](https://forum.inductiveautomation.com/t/exception-in-update-query/34481 "2020-05-06T13:59:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [May 6, 2020, 1:59pm UTC](https://forum.inductiveautomation.com/t/exception-in-update-query/34481/1 "2020-05-06T13:59:51Z")

</div>

Hello,  
I am trying to execute a update query having 3 parameters in that.  
below is my query-

query = "update [dbo].[Manual\_DowntimeEditTable] set [DowntimeEnd] = ? where lineId = ? and SideName=’%s’ and [DowntimeEnd] is NULL "  
count = system.db.runPrepUpdate(query,[endDate,lineId,side], runtimeDB)

and I am getting this exception while executing this query-

java.lang.Exception: Error executing system.db.runPrepUpdate(update [dbo].[Manual\_DowntimeEditTable] set [DowntimeEnd] = ? where lineId = ? and SideName=’%s’ and [DowntimeEnd] is NULL , [2020-05-06 12:00:00.000, 2258, 0], SFDCS\_OEE, , false, false)

What is wrong in this?  
I am using Ignition Version: 7.9.13 (b2019120915)  
Please help me to get out of this.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [May 6, 2020, 2:15pm UTC](https://forum.inductiveautomation.com/t/exception-in-update-query/34481/2 "2020-05-06T14:15:13Z")

</div>

It looks like you have more parameters in your second argument than you have references to in your query text. There are two ‘?’ in your query, so there should be two items in your list.

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [May 6, 2020, 2:18pm UTC](https://forum.inductiveautomation.com/t/exception-in-update-query/34481/3 "2020-05-06T14:18:55Z")

</div>

OK. But 3rd parameter is also there, then how pass value to 3rd parameter.

---

<div class="post-metadata">

**Author:** ![nick.schuetz](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nick.schuetz/32/6160_2.png) [@nick.schuetz](https://forum.inductiveautomation.com/u/nick.schuetz)\
**Post date:** [May 6, 2020, 2:21pm UTC](https://forum.inductiveautomation.com/t/exception-in-update-query/34481/4 "2020-05-06T14:21:11Z")

</div>

It looks like you are using ‘?’ and ‘%s’. In your case you should make the third parameter in your query also a ?..

```auto
query = "update [dbo].[Manual_DowntimeEditTable] set [DowntimeEnd] = ? where lineId = ? and SideName=? and [DowntimeEnd] is NULL"

```

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [May 6, 2020, 2:24pm UTC](https://forum.inductiveautomation.com/t/exception-in-update-query/34481/5 "2020-05-06T14:24:09Z")

</div>

ok, will try this.  
But 3rd is string parameter, is there need to write like ‘?’

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [May 6, 2020, 2:32pm UTC](https://forum.inductiveautomation.com/t/exception-in-update-query/34481/6 "2020-05-06T14:32:09Z")

</div>

You will need to use a question mark. You don’t need to put it in quotes, if that’s what you’re asking. Anywhere in the query text you put a ? will be filled by an object from the list in the second argument. When you provide a string in the list, it will be handled gracefully by the function.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [May 6, 2020, 2:33pm UTC](https://forum.inductiveautomation.com/t/exception-in-update-query/34481/7 "2020-05-06T14:33:59Z")

</div>

[The user manual documentation](https://docs.inductiveautomation.com/display/DOC79/system.db.runPrepQuery) for this function may also be useful if you haven’t seen it yet.

---

<div class="post-metadata">

**Author:** ![Anita.Shinde](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@Anita.Shinde](https://forum.inductiveautomation.com/u/Anita.Shinde)\
**Post date:** [May 6, 2020, 2:34pm UTC](https://forum.inductiveautomation.com/t/exception-in-update-query/34481/8 "2020-05-06T14:34:48Z")

</div>

Ok. Thank you so much.
