# Script won't delete rows in database

**URL:** <https://forum.inductiveautomation.com/t/script-wont-delete-rows-in-database/37485>\
**Category:** Ignition\
**Tags:** database, scripting\
**Created:** [August 6, 2020, 11:16pm UTC](https://forum.inductiveautomation.com/t/script-wont-delete-rows-in-database/37485 "2020-08-06T23:16:17Z")\
**Posts on this page:** 5\
**Page:** 2

<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:** [August 17, 2020, 8:13pm UTC](https://forum.inductiveautomation.com/t/script-wont-delete-rows-in-database/37485/21 "2020-08-17T20:13:18Z")

</div>

Your named query is expecting a parameter `id` but you are supplying a parameter `Customer_ID`. Your dictionary of parameters should be `{'id': id}`.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 17, 2020, 8:18pm UTC](https://forum.inductiveautomation.com/t/script-wont-delete-rows-in-database/37485/22 "2020-08-17T20:18:11Z")

</div>

Using this dataset, and the script below works correctly

```auto
table = event.source.parent.getComponent('Customer Power Table')
selRows = table.getSelectedRows()

if len(selRows) > 0:
	if system.gui.confirm("Are you sure you want to delete"):
  		for row in selRows:
  			id = table.data.getValueAt(row,"Customer_ID")
  			print "id: ", id

```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/c/5c115df8e6ecd6ac6479cb1bd5af0e07f8131fcd.png)

Also, @pturmel is right 😄

---

<div class="post-metadata">

**Author:** ![robb](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@robb](https://forum.inductiveautomation.com/u/robb)\
**Post date:** [August 17, 2020, 8:28pm UTC](https://forum.inductiveautomation.com/t/script-wont-delete-rows-in-database/37485/23 "2020-08-17T20:28:00Z")

</div>

Awesome, thanks!

I don’t know why the mismatch in parameters doesn’t generate an error, instead just silently exits with code 0.

---

<div class="post-metadata">

**Author:** ![robb](https://avatars.discourse-cdn.com/v4/letter/r/a183cd/32.png) [@robb](https://forum.inductiveautomation.com/u/robb)\
**Post date:** [August 17, 2020, 8:29pm UTC](https://forum.inductiveautomation.com/t/script-wont-delete-rows-in-database/37485/24 "2020-08-17T20:29:45Z")

</div>

Yes, I guess the output of 0, instead of the actual row id should have been my clue… Thanks for your help!

---

<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:** [August 17, 2020, 8:32pm UTC](https://forum.inductiveautomation.com/t/script-wont-delete-rows-in-database/37485/25 "2020-08-17T20:32:05Z")

</div>

It’s not a “code 0”, but a count of the rows affected by the SQL statement.

[Previous page](https://forum.inductiveautomation.com/t/script-wont-delete-rows-in-database/37485.md?page=1)
