Edit SQL Database from PowerTable from Client

I am attempting to update a power table from my client that is connected to a SQL database. I have a query that seems to be working, but I am pretty sure it is just setting the values to what they currently are. Every time I attempt to change a value in a cell it just returns to its old value. Here is my query:

Update Line1Sample
Set DirtyWeight = :DirtyWeight, Rock = :Rock, SampleNumber = :SampleNumber, Tops = :Tops, Mud = :Mud, Trash = :Trash, RDS = :RDS, AppPURITY = :AppPurity, PctTare = :PctTare, PercSugar = :PercSugar, POL = :POL, CleanWeight = :CleanWeight, BeetCount = :BeetCount, NScalped = :NScalped, Rocks2 = :Rocks2, RootRot = :RootRot
WHERE SampleNumber = :SampleNumber
AND SeqID = :SeqID

Any ideas to set new values to my cells through a similar update query?

Sounds like you have polling on for your database query. Try turning polling off.

How exactly are you calling this update query? Are you using the cellEdited extension function?

Also right after I type in the value that I want to change on the cell and click off of it, the cell immediately returns to its previous value. And I forgot to add that the query that is pasted above is from a button that I was using to confirm the changes.

Use triple backticks to format and copy code to the forum

put code here


# get the data from the table
data = event.source.parent.getComponent('Power Table').data

# Get the rows of the data the has highlighted
rows = event.source.parent.getComponent('Power Table').getSelectedRows()

# make sure there is something selected
if len(rows) > 0:
	if system.gui.confirm("Are you sure you want to update this information? ", "Are You Sure?",0):
		# iterate through each of the row of the list that is associated with the rows variable
		for row in rows:
			# get the value associated with the current row and the column id called "id"
			id = data.getValueAt(row, "SeqID")
			sample = data.getValueAt(row, "SampleNumber")
			dirtyWeight = data.getValueAt(row, "DirtyWeight")
			# run the query to delete from the database where tablename is the name of the database table
			system.db.runNamedQuery("Update Row", {"SeqId":id, "SampleNumber":sample, "DirtyWeight":dirtyWeight})
		system.db.refresh(event.source.parent.getComponent('Power Table'), "data")

Where is this being called, a button?

Is data query binding set to polling? It needs to be off if you want to allow the user to update the table cells without the query being re-reun and overwriting the data. If polling is on, none of this will work as expected and the user will basically be racing to press the button to save the data before the next query runs.

Yes it is a button

Still having that issue where it won’t update even after polling is off for the table.

Is the cell turning back after editing it with polling turned off?

Yes, reverts back to the value it was