I have an Oracle package which loops through a list of procedures and calls them dynamically. Prior to each procedure call, a SAVEPOINT is created, and if an exception is raised, it issues a rollback and logs the problem. A bug was recently introduced where one of the dynamic procedures had a COMMIT added to it, which when triggered, invalidates the SAVEPOINT. If that same procedure then fails (raises an exception) and the calling package's exception handler attempts to rollback, the following exception is raised inside the exception handler block:
ORA-01086: savepoint 'EXAMPLE_SAVEPOINT' never established in this session or is invalid
Now, I could put another exception handler in my exception handler, to handle this specific exception, but it would be much neater if I could do a quick check of the SAVEPOINT to see if it is valid or not immediately prior to attempting to issue the rollback. Is this possible?