Toad World® Forums

Created rudimentary exception handling (if you need it)

I posted before about the lack of exception handling in Toad workflows.

Somehow, I ran into the _ACTIVITY_RESULT system variable which is set to either "Succeeded" or specific error messages for every activity executed in a workflow. This variable gets reset after every activity so, make sure you check it immediately after the activity you're interested in (don't even add a log activity after as then it will reflect the status of the log activity - you can save it into another variable if you need to use it and reference it later on in the workflow). It's also very important to clear the checkbox "Generate Error" and "Stop on Error" in the "Activity Info" tab of the activity you want to do exception handling for. Leave the "Stop on Error" checked in the overall workflow "Settings" and only override it in the specific activity that you want to monitor for exceptions.

Case in point: I wanted to catch the "ORA-00942 - table doesn't exit" error message in one of my "Select to file" activities. Immediately after the "Select to file" activity, I added an "if" statement with the first condition on the far most left (the if conditions are evaluated left to right, apparently) as such "Instr('#_ACTIVITY_RESULT#', 'ORA-00942')<=0 and Instr('#_ACTIVITY_RESULT#', 'Succeeded')<=0". This says that if the _ACTIVITY_RESULT variable is not "Succeeded" and not "ORA-00942" (which is the exception I wanted to catch and ignore), then I'll throw an exception by using the "Throw Error" activity (some other error happened). The other part of the if statement (the one to the right) is a "1=1" or "true" condition so I can continue with my workflow.

Quest folks: I would think that something similar to what I've described above could be encapsulated into a "Catch Exception" activity which would take as parameter a list of String exception text.

Select to File:

First if statement branch:

Second if statement branch: