Try Catch on a Database Reader

Hi, I’m trying to configure a workflow to read from a Database Reader node. The workflow runs in a loop, and for most of my cases the information I need is in a consistently named table, but on some older cases I need to look for a different table name.

My plan was to use a Try Catch loop so if the main reader failed it would pull the results from the backup source:
image
The database connection is coming from elsewhere and feeds into multiple other points of the workflow, so is outside of this try-catch loop. There aren’t nodes (that I can see?) for Try with anything other than Data or Variable, so I’ve used a variable to just connect into the Database Reader.

When I run the Catch node, both DB Readers execute and the main one fails as expected, but instead of reading the backup source (which is successful) I don’t get an output from the catch. Am I going about this the wrong way?

Aha, to potentially answer my own question, I think this was the issue:
image

This means the first database reader will attempt to run and fail and the catch loop then goes to the backup option successfully.
image

2 Likes

Hi @phick , if your solution resolves your problem, then feel free to mark it as the solution so that others may find the solution more easily. Or if you still have questions then please ask away. And thanks for sharing! :slight_smile:

1 Like

Yes, I think I’ve just forgotten about the option of the SQL running at point of configuration and point of execution. Since I expect one or the other of them to fail, I need it to wait until it actually runs and then fails so the Try-Catch can work as I intended.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.