# runPrepUpdate Insert Failing

**URL:** <https://forum.inductiveautomation.com/t/runprepupdate-insert-failing/11172>\
**Category:** Ignition\
**Created:** [February 5, 2016, 7:43pm UTC](https://forum.inductiveautomation.com/t/runprepupdate-insert-failing/11172 "2016-02-05T19:43:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jreynolds](https://avatars.discourse-cdn.com/v4/letter/j/58956e/32.png) [@jreynolds](https://forum.inductiveautomation.com/u/jreynolds)\
**Post date:** [February 5, 2016, 7:43pm UTC](https://forum.inductiveautomation.com/t/runprepupdate-insert-failing/11172/1 "2016-02-05T19:43:53Z")

</div>

This insert query keeps failing, can anyone see why? I’m executing this from an SFC.

[code]   
res = chart.resource  
str = chart.startTime  
staID = chart.staID  
jobNum = chart.jobNum

```
system.db.runPrepUpdate("INSERT INTO help_events (res_id, event_str, sta_id, job_num) VALUES (?,?,?,?)",
[res, str, staID, jobNum], 'Wentzville_MO')[/code]

```

[code] 1:40:22 PM com.inductiveautomation.sfc.ChartInstance Chart ‘Wentzville/HelpSeq’ aborted.

Traceback (most recent call last):  
File “”, line 15, in onStart  
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:362)

at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runPrepUpdate(AbstractDBUtilities.java:260)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

java.lang.Exception: java.lang.Exception: Error executing system.db.runPrepUpdate(INSERT INTO help\_events (res\_id, event\_str, sta\_id, job\_num) VALUES (?,?,?,?), [2, Fri Feb 05 13:40:22 CST 2016, 0, 0], Wentzville\_MO, , false, false)

at org.python.core.Py.JavaError(Py.java:495)  
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.error(AbstractDBUtilities.java:362)  
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runPrepUpdate(AbstractDBUtilities.java:260)  
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)  
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
at java.lang.reflect.Method.invoke(Unknown Source)  
at org.python.core.PyReflectedFunction. **call** (PyReflectedFunction.java:186)  
at com.inductiveautomation.ignition.common.script.ScriptManager$ReflectedInstanceFunction. **call** (ScriptManager.java:428)  
at org.python.core.PyObject. **call** (PyObject.java:422)  
at org.python.core.PyObject. **call** (PyObject.java:426)  
at org.python.pycode._pyx3682.onStart$1(:15)  
at org.python.pycode.pyx3682.call\_function()  
at org.python.core.PyTableCode.call(PyTableCode.java:165)  
at org.python.core.PyBaseCode.call(PyBaseCode.java:301)  
at org.python.core.PyFunction.function\_\_\_call_(PyFunction.java:376)  
at org.python.core.PyFunction. **call** (PyFunction.java:371)  
at org.python.core.PyFunction. **call** (PyFunction.java:361)  
at org.python.core.PyFunction. **call** (PyFunction.java:356)  
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:637)  
at com.inductiveautomation.sfc.elements.steps.StepScriptRunner.invoke(StepScriptRunner.java:44)  
at com.inductiveautomation.sfc.elements.steps.StepScriptRunner.invoke(StepScriptRunner.java:32)  
at com.inductiveautomation.sfc.elements.steps.action.ActionStep.activateStep(ActionStep.java:53)  
at com.inductiveautomation.sfc.elements.StepContainer.activateStep(StepContainer.java:46)  
at com.inductiveautomation.sfc.elements.AbstractBasicStepElement.onActivateRequested(AbstractBasicStepElement.java:92)  
at com.inductiveautomation.sfc.fsm.element.ElementInactive.action(ElementInactive.java:33)  
at com.inductiveautomation.sfc.fsm.element.ElementInactive.action(ElementInactive.java:8)  
at com.inductiveautomation.sfc.fsm.StateContext.lambda$handleEvent$14(StateContext.java:52)  
at com.inductiveautomation.sfc.fsm.StateContext$$Lambda$721/1486015562.run(Unknown Source)  
at com.inductiveautomation.sfc.api.ExecutionQueue$PollAndExecute.run(ExecutionQueue.java:111)  
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)  
at java.util.concurrent.FutureTask.run(Unknown Source)  
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)  
at java.lang.Thread.run(Unknown Source)  
Caused by: java.lang.Exception: Error executing system.db.runPrepUpdate(INSERT INTO help\_events (res\_id, event\_str, sta\_id, job\_num) VALUES (?,?,?,?), [2, Fri Feb 05 13:40:22 CST 2016, 0, 0], Wentzville\_MO, , false, false)  
… 34 more  
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: The conversion from UNKNOWN to UNKNOWN is unsupported.  
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170)  
at com.microsoft.sqlserver.jdbc.DataTypes.throwConversionError(DataTypes.java:946)  
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObject(SQLServerPreparedStatement.java:958)  
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObjectNoType(SQLServerPreparedStatement.java:910)  
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.setObject(SQLServerPreparedStatement.java:919)  
at org.apache.commons.dbcp.DelegatingPreparedStatement.setObject(DelegatingPreparedStatement.java:166)  
at com.inductiveautomation.ignition.gateway.datasource.SRConnectionWrapper$SRPreparedStatement.setObject(SRConnectionWrapper.java:971)  
at com.inductiveautomation.ignition.gateway.datasource.SRConnectionWrapper.runPrepUpdate(SRConnectionWrapper.java:160)  
at com.inductiveautomation.ignition.gateway.script.GatewayDBUtilities.\_runPrepStmt(GatewayDBUtilities.java:108)  
at com.inductiveautomation.ignition.common.script.builtin.AbstractDBUtilities.runPrepUpdate(AbstractDBUtilities.java:258)[/code]

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [February 8, 2016, 1:34am UTC](https://forum.inductiveautomation.com/t/runprepupdate-insert-failing/11172/2 "2016-02-08T01:34:56Z")

</div>

What data types are being used by the 4 columns in the database table?

Perhaps a Python type you are using doesn’t correspond to a column type in the database table.

Best,

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [February 8, 2016, 6:03am UTC](https://forum.inductiveautomation.com/t/runprepupdate-insert-failing/11172/3 "2016-02-08T06:03:53Z")

</div>

In fact your “event\_str” column seems like it might be a string data type like a VARCHAR. But the value you are trying to insert is a Java Date, not a string. That won’t work. You will need to convert the date object to a string first, before trying to insert it.
