# runPrepUpdate not updating?

**URL:** <https://forum.inductiveautomation.com/t/runprepupdate-not-updating/98921>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [November 21, 2024, 9:52am UTC](https://forum.inductiveautomation.com/t/runprepupdate-not-updating/98921 "2024-11-21T09:52:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [November 21, 2024, 9:52am UTC](https://forum.inductiveautomation.com/t/runprepupdate-not-updating/98921/1 "2024-11-21T09:52:49Z")

</div>

I have this query that works:

```python
UPDATE DTIM_TIME_TABLE
SET LEVEL6ID = 'TEST'
WHERE LEVEL5ID IN ('TEST', 'TEST1')

```

but this doesn't:

```python
list2 = [
	"TEST",
	"TEST1"
]

r = '(' + ', '.join(["'%s'" % (l) for l in list2]) + ')'
# r = ('TEST', 'TEST1')

system.db.runPrepUpdate(
	"UPDATE DTIM_TIME_TABLE SET LEVEL6ID = 'TEST' WHERE LEVEL5ID IN ?",
	[r]
)

```

I'm dumb? Any idea?  
Thanks in advance

---

<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:** [November 21, 2024, 10:13am UTC](https://forum.inductiveautomation.com/t/runprepupdate-not-updating/98921/2 "2024-11-21T10:13:37Z")

</div>

You're not dumb. It was discussed a few times on the forum. Here's one from eight years ago.

> [@Update with IN condition](https://forum.inductiveautomation.com/t/update-with-in-condition/11679/3):
>
> You cannot pass a list into a single ‘?’ substitution parameter. Jordan’s suggestion would be suitable in your case if you use ‘%s’ instead of ‘?’ and use the non-Prep form of the query. When using data types in a list that would be problematic when converted to a string, you must place one ‘?’ for each element of list. Like so:system.db.runPrepUpdate("UPDATE TEST SET FL= 1 WHERE ID IN (%s)" % (", ".join(['?'] \* len(y))), y, "dscada\_main")

---

<div class="post-metadata">

**Author:** ![danielps1818](https://avatars.discourse-cdn.com/v4/letter/d/ecae2f/32.png) [@danielps1818](https://forum.inductiveautomation.com/u/danielps1818)\
**Post date:** [November 21, 2024, 10:46am UTC](https://forum.inductiveautomation.com/t/runprepupdate-not-updating/98921/3 "2024-11-21T10:46:25Z")

</div>

Just as documentation. I ended using `system.db.runQuery()` and I simply build the string.

```python
statement = 'UPDATE DTIM_TIME_TABLE SET LEVEL6ID = 'TEST' WHERE LEVEL5ID IN "
r = '(' + ', '.join(["'%s'" % (l) for l in list2]) + ')'

query = statement + r
# \_> UPDATE DTIM_TIME_TABLE SET LEVEL6ID = 'TEST' WHERE LEVEL5ID IN ('TEST', 'TEST1')

system.db.runQuery(query)

```

---

<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:** [November 21, 2024, 12:10pm UTC](https://forum.inductiveautomation.com/t/runprepupdate-not-updating/98921/4 "2024-11-21T12:10:19Z")

</div>

> [@danielps1818](#):
>
> I simply build the string.

That is extremely unsafe for quoted strings as you show. Don't do that. Anyone encountering this topic in the future is highly encouraged to **not** follow Daniel's example.
