Exception in update query

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.

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.

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

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

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

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

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.

The user manual documentation for this function may also be useful if you haven’t seen it yet.

Ok. Thank you so much.