I just wrote what feels like a very hacky script but I don't know that there's a better way to do this and maybe there isn't but I wanted to check with the pros here.
I have a function that runs a bunch of named queries in a transaction.
At one point, I have to compare two datasets to each other before determine what the next query to run is.
The issue is sometimes these datasets can be large, and then I'm not doing anything in the transaction for a extended amount of time which then leads the transaction to closing itself and then I get an error when I finally determine the next query - the transactions already closed.
Right now my "fix" is during my dataset comparison part to do this
for row in range(savedList.rowCount): if row % 10 == 0: system.db.runNamedQuery('Util/keepTransactionAlive', tx=tx) for row2 in range(initialList.rowCount): # do stuff
Is this a normal pattern for this sort of scenario or is there a better way to handle this?