DB2 exception processor is still unfamiliar to many new users who have just been familiar with the DB2 database. Next we will introduce the DB2 exception Processor type for you. I hope it will help you.
DB2 exception Processor type (handler-type) has the following types:
After the processor operation is complete, CONTINUE continues to execute the next statement after the exception statement is generated.
After the processor operation is complete, EXIT terminates the stored procedure and returns the control to the caller.
Before UNDO executes a processor operation, DB2 rolls back the SQL operations performed during the stored procedure. After the processor operation is complete, the stored procedure is terminated and the control is returned to the caller.
Exception processors can handle custom exceptions based on specific SQLSTATE values or classes with predefined exceptions. The predefined three types of exceptions are as follows:
The not found flag causes an exception where the SQLCODE value is + 100 or the SQLSATE value is 02000. This exception usually occurs when SELECT does not return rows.
An error occurs when the SQLCODE value is negative due to the sqlexceptioin id.
The SQLWARNING flag causes a warning exception or an exception that causes a SQLCODE value other than 100.
If a not found or SQLWARNING exception is generated and no exception processor is defined for the exception, the exception is ignored and the control flow is switched to the next statement. If an SQLEXCEPTION exception is generated and no exception processor is defined for this exception, the stored procedure fails and the control flow is returned to the caller.
The EXIT processor is called when an SQLEXCEPTION or SQLWARNING exception occurs. Before terminating the SQL program, the EXIT processor sets the variable named stmt to "ABORTED" and returns the control flow to the caller. The UNDO processor rolls back the SQL Operations completed in the Stored Procedure body before returning the control flow to the caller.
DB2 lock compatibility and deadlock
Deep Analysis of DB2 Lock Mechanism
Implementation of adding verification constraints to DB2
How to Create a tablespace in DB2
Introduction to the DB2 user group in Linux