Exception Handling in Stored Procedure


Exception Handling in Stored Procedure



I have a stored procedure where i am executing SQL scripts in loop. The SQL Scripts are stored as value in a table.So the Stored Procedure i have designed in such a way that one by one it picks up the sql from this table and executes and stores the result into another table called RESULT_SUMMARY whether the scripts 'Pass' or 'Fail'. Basically i have designed this to automate test script execution.


The issue currently is that lets say out of 100 test cases, the 5th test script fails due to some syntax error like "Table does not exist", then the rest of the pending scripts do not execute further. The Stored Procedure stops there itself.


What can i use to resolve this issue?

Is it possible to skip the script which has error and execute the rest of the test scripts which are in queue?




Junior Contributor

Re: Exception Handling in Stored Procedure

You need to define BEGIN/END-block with a CONTINUE-handler around the EXECUTE IMMEDIATE