# Error system.db.runPrepUpdate

**URL:** <https://forum.inductiveautomation.com/t/error-system-db-runprepupdate/10264>\
**Category:** Ignition\
**Created:** [July 23, 2015, 5:21pm UTC](https://forum.inductiveautomation.com/t/error-system-db-runprepupdate/10264 "2015-07-23T17:21:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrea.montresor](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@andrea.montresor](https://forum.inductiveautomation.com/u/andrea.montresor)\
**Post date:** [July 23, 2015, 5:21pm UTC](https://forum.inductiveautomation.com/t/error-system-db-runprepupdate/10264/1 "2015-07-23T17:21:22Z")

</div>

Hello,

I tried to enter in the changed value of a tag the following script:  
valore = 110  
system.db.runPrepUpdate(“UPDATE scd\_command SET id\_command\_status = 25 WHERE cd\_command = (?)”, [valore])

But when I change the value I get this error:  
[b]Value Changed Error executing script.  
Traceback (most recent call last):  
File “tagevent:valueChanged”, line 17, in valueChanged  
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(UPDATE scd\_command SET id\_command\_status = 25 WHERE cd\_command = (?), [110], , , false, false)  
ERROR[/b]

I attach photos.  
How can I fix this error?

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/aa3bf60c62c5ecfa4b0838c69a4f54b9fc34290a.png)  
  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/2db7c7ac257a5711ba940de78787006c77707715.png)

---

<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:** [July 23, 2015, 5:34pm UTC](https://forum.inductiveautomation.com/t/error-system-db-runprepupdate/10264/2 "2015-07-23T17:34:17Z")

</div>

You can fix it by supplying the database argument in the system.db.runPrepUpdate function call.

When the database argument is not supplied a project’s default datasource is used. That doesn’t work in this case because a Tag Event script is not associated with a project.

Best,

---

<div class="post-metadata">

**Author:** ![andrea.montresor](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@andrea.montresor](https://forum.inductiveautomation.com/u/andrea.montresor)\
**Post date:** [July 23, 2015, 6:42pm UTC](https://forum.inductiveautomation.com/t/error-system-db-runprepupdate/10264/3 "2015-07-23T18:42:56Z")

</div>

Thanks a lot!

I have one more question. I put in the script the name of the database connection (dscada\_main) like this:

`valore = 110
system.db.runPrepUpdate("UPDATE scd_command SET id_command_status = 25 WHERE cd_command = (?)", [valore] ,dscada_main)`

This is the syntax:  
system.db.runPrepUpdate(query, args, database, tx, getKey, skipAudit)  
Parameters  
String database - The name of the database connection to execute against. If omitted or “”, the project’s default database connection will be used.

But it gives me this error:  
Value Changed Error executing script.  
Traceback (most recent call last):  
File “tagevent:valueChanged”, line 17, in valueChanged  
NameError: global name ‘dscada\_main’ is not defined  
ERROR

Can you help me?

Thanks

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/6486b22f3db14bd406434ad921e5efb28b938584.png)

---

<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:** [July 23, 2015, 6:46pm UTC](https://forum.inductiveautomation.com/t/error-system-db-runprepupdate/10264/4 "2015-07-23T18:46:38Z")

</div>

Yes.

Use a string argument, like this:

```auto
valore = 110
system.db.runPrepUpdate("UPDATE scd_command SET id_command_status = 25 WHERE cd_command = (?)", [valore] ,"dscada_main")
```

---

<div class="post-metadata">

**Author:** ![andrea.montresor](https://avatars.discourse-cdn.com/v4/letter/a/5f9b8f/32.png) [@andrea.montresor](https://forum.inductiveautomation.com/u/andrea.montresor)\
**Post date:** [July 24, 2015, 6:15am UTC](https://forum.inductiveautomation.com/t/error-system-db-runprepupdate/10264/5 "2015-07-24T06:15:06Z")

</div>

Now it works.

Thanks a lot!

Andrea
