Nested Compound Statements And Exception Handlers - Sybase Adaptive Server IQ 12.4.2 Administration And Performance Manual

Table of Contents

Advertisement

Exception handling
and atomic compound
statements

Nested compound statements and exception handlers

Drop the procedures
If the error handling code for the
a RESIGNAL statement, control is passed back to the
with SQLSTATE still set at the value 52003. This is just as if there were
no error handling code in
, the procedure fails.
OuterProc
When an exception is handled inside a compound statement, the compound
statement completes without an active exception and the changes before the
exception are not undone. This is true even for atomic compound statements.
If an error occurs within an atomic compound statement and is explicitly
handled, some but not all of the statements in the atomic compound statement
are executed.
The code following a statement that causes an error is not executed unless an
ON EXCEPTION RESUME clause is included in a procedure definition.
You can use nested compound statements to give you more control over which
statements are and are not executed following an error.
Remember to drop both the
continuing with the tutorial. You can do this by entering the following
commands in the command window:
DROP PROCEDURE OUTERPROC;
DROP PROCEDURE INNERPROC
The following demonstration procedure illustrates how nested compound
statements can be used to control flow. The procedure is based on that used as
an example in "Default error handling in procedures" on page 256
CREATE PROCEDURE InnerProc()
BEGIN
DECLARE column_not_found
EXCEPTION FOR SQLSTATE VALUE '52003';
MESSAGE 'Hello from InnerProc';
BEGIN
SIGNAL column_not_found;
MESSAGE 'Line following SIGNAL'
EXCEPTION
WHEN column_not_found THEN
MESSAGE 'Column not found handling';
WHEN OTHERS THEN
RESIGNAL;
CHAPTER 6
Using Procedures and Batches
column not found
. As there is no error handling code in
InnerProc
and
InnerProc
OuterProc
exception is simply
procedure
OuterProc
procedures before
263

Advertisement

Table of Contents
loading

Table of Contents