Can't execute multiple runNamedQuery updates

I run a script for a button input in Perspective. I want to update two tables in a database. I run system.db.runNamedQuery(query, params) which works followed by system.db.runNamedQuery(query2, params2) which doesn’t work. If I run query2 first system.db.runNamedQuery(query2, params2) it works followed by system.db.runNamedQuery(query, params) which doesn’t work. What’s going on?

This obviously isn’t expected behavior. Is there anything in the logs? Have you wrapped it in a try-except block to see if any exceptions are thrown?


I was able to work around the problem by adding multiple scripts. Each script has it’s own runNamedQuery which now works fine and updates a record in each table after pushing the button.

I encountered something similar a long time ago and had to incorporate system.db.beginNamedQueryTransaction along with system.db.commitTransaction. Once I did that the Script which had multiple Named Queries worked correctly.

It seems like a Named Query commits when a Script Action completes, but not before. If you ned to run multiple named queries, you need to either run them in one batch or commit the previous batch.

Definitely not intended behavior outside of transactions. Sounds like a bug to me.

@KathyApplebaum, was this captured as a bug? I’m still seeing this behavior in 8.1.2.

Thanks @cmallonee for the workaround!