Handler declarations
- Last Updated: November 7, 2022
- 1 minute read
- DataDirect Connectors
- JDBC
- Autonomous REST Connector 6.0
- Documentation
The following syntax is used to declare how error handlers handle exceptions when they
occur.
DECLARE [UNDO | CONTINUE | EXIT] HANDLER FOR [SQLEXCEPTION | SQLWARNING | NOT FOUND
SQLSTATE <sql_state>[, ...]] [<procedural_statement>]where:
- UNDO
- specifies that all the changes made inside the block are undone before executing the statement after the block, if any.
- CONTINUE
- specifies that the exception is ignored, then the next iteration or statement after the block, if any, is executed.
- EXIT
- specifies that the block is terminated, but any successful changes are preserved.
- SQLEXCEPTION
- specifies that the procedural statement is to be executed when a SQL exception is encountered.
- SQLWARNING
- specifies that procedural statement to be executed when a SQL warning is encountered.
- NOT FOUND
- specifies that the procedural statement is to be executed when a DELETE, UPDATE, INSERT, or MERGE statement is executed without affecting any rows.
- SQLSTATE
- specifies that the procedural statement is to be executed when the specified SQLSTATE code is encountered.
- sql_state
- specifies the five-character SQLSTATE code. For example,
HY000. - procedural_statement
- (optional) specifies the procedural statement to be executed when the conditions in the declaration are encountered.