Choose an exception-handling strategy
By default, the application does not perform any exception handling for SQL statements. Therefore, unless you explicitly provide such code, execution continues when an exception occurs. While this behavior might not be too serious for successful execution, warnings, and NOT FOUND conditions, it can have serious consequences in the event of a runtime error.
A runtime error might halt the program execution. Unless you check for and handle these errors in the application code, this behavior can cause the user confusion and annoyance. It also can leave the application in an inconsistent state.
Within the application,
choose a consistent strategy for exception handling. You can choose
one of the following exception-handling strategies:
- You can check after each SQL statement, which means that you include code to test the value of SQLSTATE (or SQLCODE) after each SQL statement.
- You can use the WHENEVER statement to associate a response to take each time a particular type of exception occurs.
Important: Consider how to perform exception handling
in an application before you begin development so that you take a
consistent and maintainable approach.