# Why am I using runPrepUpdate incorrectly?

**URL:** <https://forum.inductiveautomation.com/t/why-am-i-using-runprepupdate-incorrectly/6846>\
**Category:** Ignition\
**Created:** [July 10, 2013, 10:57pm UTC](https://forum.inductiveautomation.com/t/why-am-i-using-runprepupdate-incorrectly/6846 "2013-07-10T22:57:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RossStewart](https://avatars.discourse-cdn.com/v4/letter/r/edb3f5/32.png) [@RossStewart](https://forum.inductiveautomation.com/u/RossStewart)\
**Post date:** [July 10, 2013, 10:57pm UTC](https://forum.inductiveautomation.com/t/why-am-i-using-runprepupdate-incorrectly/6846/1 "2013-07-10T22:57:24Z")

</div>

This gives me the old syntax error. (on the last line)

[quote]# get new value  
value = event.newValue

# get row for new value (local table)

row = event.row

# get column for new value in local table

col = event.column

# get selected column name for db update

data = event.source.data  
colname = data.getColumnName(col)

# get ID for database update

IDnum = data.getValueAt(row,“ID”)  
#change DB to reflect edited table  
system.db.runPrepUpdate(“UPDATE stimprogram SET ?=? WHERE ID=?”,[colname,value,IDnum], “CHCFG”[/quote]

---

<div class="post-metadata">

**Author:** ![pdibenedetto](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pdibenedetto/32/6364_2.png) [@pdibenedetto](https://forum.inductiveautomation.com/u/pdibenedetto)\
**Post date:** [July 10, 2013, 11:28pm UTC](https://forum.inductiveautomation.com/t/why-am-i-using-runprepupdate-incorrectly/6846/2 "2013-07-10T23:28:07Z")

</div>

The column name cannot be mapped using the question character.

Try this:

```auto
query = "UPDATE stimprogram SET %s=? WHERE ID=?" % (colname)
system.db.runPrepUpdate(query, [value,IDnum], "CHCFG")
```

---

<div class="post-metadata">

**Author:** ![RossStewart](https://avatars.discourse-cdn.com/v4/letter/r/edb3f5/32.png) [@RossStewart](https://forum.inductiveautomation.com/u/RossStewart)\
**Post date:** [July 11, 2013, 7:48pm UTC](https://forum.inductiveautomation.com/t/why-am-i-using-runprepupdate-incorrectly/6846/3 "2013-07-11T19:48:09Z")

</div>

Thanks, that worked. ![:prayer:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e5a7e3b63facc151ea73e3b45db7bdb3d4bdc316.gif ":prayer:")

---

<div class="post-metadata">

**Author:** ![pdibenedetto](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pdibenedetto/32/6364_2.png) [@pdibenedetto](https://forum.inductiveautomation.com/u/pdibenedetto)\
**Post date:** [July 13, 2013, 4:20pm UTC](https://forum.inductiveautomation.com/t/why-am-i-using-runprepupdate-incorrectly/6846/4 "2013-07-13T16:20:07Z")

</div>

Glad that been worked. ![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")

Please, mark this topic as solved.

Regards,
