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.
- 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.