Query doesn't execute in lag

I run this event script on a button to update a table created and controlled by a standard transaction group that uses an hour meter to update the last row of my table. I thought this would be a good way to clear an entire column of data and ever a new value in the last row of the database.
When I click this button on one of my more laggy windows, it runs through the script and closes the window but does not run the update query.
When I keep this popup open and close the laggy window and try the button again, It works all the time.
My transaction group is set up as bidirectional DB wins and I did try to set OPC wins and it worked a little better on the laggy window which seemed backwards to me.

queryValue = event.source.parent.getComponent(‘Numeric Text Field’).floatValue
same = event.source.parent.MotorID
system.db.runUpdateQuery(“UPDATE motorrun SET [%s] = 0” % (same), ‘NewConnection’)
system.db.runUpdateQuery(“UPDATE motorrun SET [%s] = %f WHERE motorrun_ndx = (SELECT MAX(motorrun_ndx) FROM motorrun)” % (same,queryValue) , ‘NewConnection’)
system.nav.closeParentWindow(event)

also, occasionally when I run this script with a new value, it will change it in the database to, not the NEW value, but instead will cast the old value from float to int. So, if I had 55.6 then entered 80, and ran the script, it would change to 55.
I’m wondering what the interplay is with my update query and the transaction group which runs this database. Increasing my exec timing to 30 seconds did not appear to change anything either.
I’ve got a scrolling marquee on my laggy window too, and as I try to run this script, if the marquee is moving, the update usually works, it its stalled… It fails.
Any idea whats going on here?

Ok that was a lot of information.

If it is running through the script, then it IS running the queries. Perhaps something else is then altering the table? Use printouts to convince yourself that the script you’re looking at is the script that is running.

Use a prepared update to avoid putting the float in a string - that should help with your type casting.

Switching this to use a prep update will mean I will use ? marks instead of the % python placeholders in my querys?
Something like?

queryValue = event.source.parent.getComponent('Numeric Text Field').floatValue same = event.source.parent.MotorID system.db.runPrepUpdate("UPDATE motorrun SET (?) = 0" , [same], 'NewConnection') system.db.runPrepUpdate("UPDATE motorrun SET (?) = (?) WHERE motorrun_ndx = (SELECT MAX(motorrun_ndx) FROM motorrun)" [same,queryValue] , 'NewConnection') system.nav.closeParentWindow(event)
I don’t think my question marks are in the right place.

You can 't use a ? in place of a table name or column name since Ignition will put single quotes around it to treat as a string.queryValue = event.source.parent.getComponent('Numeric Text Field').floatValue same = event.source.parent.MotorID system.db.runPrepUpdate("UPDATE motorrun SET (%s) = 0" % same, [], 'NewConnection') system.db.runPrepUpdate("UPDATE motorrun SET (%s) = (?) WHERE motorrun_ndx = (SELECT MAX(motorrun_ndx) FROM motorrun)" % same, [queryValue] , 'NewConnection') system.nav.closeParentWindow(event)

I changed my code to match what you have Travis.
It seems to work with the same reliability as with the runUpdateQuery code…
In laggy windows, it fails…
In empty windows, it works.
I’m looking at the database and the transaction group the writes to it, still havent found the problem.

Did you put the print statements in to verify that the script is running or not like Carl suggested?

my code looks like:

queryValue = event.source.parent.getComponent('Numeric Text Field').floatValue same = event.source.parent.MotorID system.db.runPrepUpdate("UPDATE motorrun SET[%s] = 0" % (same), [],'NewConnection') system.db.runPrepUpdate("UPDATE motorrun SET [%s] = (?) WHERE motorrun_ndx = (SELECT MAX(motorrun_ndx) FROM motorrun)" % (same), [queryValue] , 'NewConnection') print "something" system.nav.closeParentWindow(event)

When I run this is a slow window it does not print although it does occasionally run the query (without the print)
In a fast window, it runs the query every time without printing.

Are you getting any timeout errors? The only way you won’t get to the print statement is if any of the lines above it errors out.

The last line closes the window, right?
So, if it closes the window, it would have to make the print above that…
No Travis, I don’t see any errors for this.

That is right. If it is closing the window the print statement has to run. There is no way for it not to. The console can be hard to read when errors happen. Are you sure you don’t see the print in there? I think you need to call our tech support for this one so we are all on the same page.

It seems like this is related to the lag which I’m hoping will go away after the combine repaints fix for the templates.
I’ve revisited this today and can’t seem to correct my code and transaction group to handle this.
I’m going to wait until the update to call.