# Error SQL Update for SQL

**URL:** <https://forum.inductiveautomation.com/t/error-sql-update-for-sql/84613>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 23, 2024, 7:27am UTC](https://forum.inductiveautomation.com/t/error-sql-update-for-sql/84613 "2024-01-23T07:27:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hisyam\_agung](https://avatars.discourse-cdn.com/v4/letter/h/9dc877/32.png) [@hisyam\_agung](https://forum.inductiveautomation.com/u/hisyam_agung)\
**Post date:** [January 23, 2024, 7:27am UTC](https://forum.inductiveautomation.com/t/error-sql-update-for-sql/84613/1 "2024-01-23T07:27:20Z")

</div>

I try to update database when click button.  
Nothing message "Error" and the weird thing is that yesterday it worked and when I tried again today, the update function did not work.

Script button :

```auto
	pic = self.getSibling("pic").props.text
	rootcause = self.getSibling("rootcause").props.text
	countermeasure = self.getSibling("countermeasure").props.text
	status = self.getSibling("status").props.value
	reponsedate = self.getSibling("responsedate").props.text
	defect_name = self.getSibling("defect_name").props.text
	
	system.db.runNamedQuery("Update_Report", {"pic": pic, "rootcause": rootcause, "countermeasure": countermeasure, "status": status, "reponsedate": reponsedate, "defect_name": defect_name})	
	system.perspective.closePopup('')

```

Named Query :

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/1/71515fced13a5434f6cdfee05a97aaa48826e78a.png)

And I tried to update data manual from SQL and success  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fbee8a6352be8bfd88ed9ae8edb2cc3ea95f1a69.png)

I often have this problem when creating scripts on buttons (whether it's filters or data updates)

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [January 23, 2024, 3:47pm UTC](https://forum.inductiveautomation.com/t/error-sql-update-for-sql/84613/2 "2024-01-23T15:47:33Z")

</div>

The one thing I can think of that would give you inconsistent behavior is if your `defect_name` could be different then what the `defect_name` is in the database. It looks like an entered field, so if a user entered `'BOCOOR'` or `'BOCOR '` then your `WHERE` clause would not match a defect name and thus not update the record.

---

<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:** [January 23, 2024, 4:03pm UTC](https://forum.inductiveautomation.com/t/error-sql-update-for-sql/84613/3 "2024-01-23T16:03:34Z")

</div>

Your should capture the return value from `system.db.runNamedQuery()`. It gives the number of rows affected by the update. You can use that to provide feedback to the user.

---

<div class="post-metadata">

**Author:** ![hisyam\_agung](https://avatars.discourse-cdn.com/v4/letter/h/9dc877/32.png) [@hisyam\_agung](https://forum.inductiveautomation.com/u/hisyam_agung)\
**Post date:** [January 24, 2024, 2:15am UTC](https://forum.inductiveautomation.com/t/error-sql-update-for-sql/84613/4 "2024-01-24T02:15:59Z")

</div>

Sorry my bad, this error solving by changed "reponsedate" from ":reponsedate" to be CURRENT\_TIMESTAMP
