As @lrose said, you're using a regular transaction for named queries. Use a namedQueryTransaction.
But I also agree with him: That's hardly transaction-worthy. If you're never rolling back...
In this particular case, I'd probably just build the query dynamically and use runPrepUpdate just once.
something like
q = """
delete from your_table
where id in ({})
""".format(','.join('?' * len(selRows)))
system.db.runPrepUpdate(q, [product['ProductID'] for product in selRows])
Also, don't use id as a variable name, it's a built-in identifier. While it may not cause any harm in this situation, I suggest never using built-in names for your own stuff.
def onMessageReceived(self, payload):
self.getSibling("Status").props.text = "TEXT1"
# Get the selected row or rows.
selRows = self.getSibling('Table').props.selection.data
# Check to see that a row is actually selected.
if len(selRows) > 0:
# If the user gave confirmation, we need to loop through all of them.
for row in selRows:
# For each selected row, we need to get the value of the id column in that row.
productid = row["ProductID"]
self.getSibling("Status").props.text = "TEXT1"
# Use the id of the row to delete it from the database table.
system.db.runNamedQuery("Configurations/DeleteProduct", {"ID":productid})
self.getSibling("Status").props.text = "Successfully deleted"
else:
self.getSibling("Status").props.text = "Error: No row(s) selected"
I would almost guarantee that you're getting an error. Look in the gateway logs an see if you have any errors. At this point, it's going to be difficult to help you any further. My guess is that is trying to execute but there is some other issue preventing it.
Ok hear me out. Sometimes a product cannot be deleted due to being referenced somewhere. I only want to delete if every elected product can be deleted. Wouldn't that be transaction worthy? Rollback if one fails. Commit if they all pass. Or is there a more worthy way?