Handling SQL exceptions

Hi all,
I was wondering if there was a way we can catch SQL exceptions before the message box is shown. I’ve tried putting the SQL calls in a try/catch and expected the open catch: to get the SQL exception, but the message box still pops up. The broader issue is that I get FPMI to update a table, but before the table is updated I get SQL errors every second that I’d like to suppress.


Please post a screenshot or the exact “SQL Error”

You’re updating the table via scripting? Or is the table’s dataSet bound to a (sometimes) invalid query?

Basically I’ve been asked to set up configurable timeouts (the lock screen and logout ones) for each user, so I added two columns to the user table. The problem is I don’t have access to the customer’s database (from here at least) so I’ve set the system up to check if the two columns have been added on startup, and if they haven’t it adds them. The issue is that before the table is updated SQL errors are thrown by the global timer that checks if the user has timed out. The errors aren’t critical or anything, I just like seeing no errors :slight_smile:. So I have two questions:
-Is there some way we can catch the SQL errors before the message box is shown?
-Is there a way to enable/disable a global event timer in code?

In response to your questions, the error was that the column doesn’t exist and I’m doing the table update in the startup code section.


  1. Yes, you should be able to catch these errors:

try: fpmi.db.runQuery(...) except: pass #ignore errors

  1. Yes, sure you can disable your timer script from running. Its code- you can do whatever you want.

global shouldIRun if shouldIRun: ... do something

See the user manual under Technical Reference / Jython / Global Script Module / Tips & Tricks - Global Variables for more on setting up global variables in a safe way.

Excellent, thanks a lot!