Sybase 12.4.2 User Manual

Page 277

Advertising
background image

CHAPTER 6 Using Procedures and Batches

257

Notes

The DECLARE statement in

InnerProc

declares a symbolic name for one

of the predefined SQLSTATE values associated with error conditions
already known to the server. The DECLARE statement does not take any
other action.

The MESSAGE statement sends a message to the server window and the
dbconsol message window.

The SIGNAL statement generates an error condition from within the

InnerProc

procedure.

The following statement executes the

OuterProc

procedure:

CALL OuterProc();

The message window of the server then displays the following:

Hello from OuterProc.

Hello from InnerProc.

No statements following the SIGNAL statement in

InnerProc

are executed:

InnerProc

immediately passes control back to the calling environment, which

in this case is the procedure

OuterProc

. No statements following the CALL

statement in

OuterProc

are executed. The error condition is returned to the

calling environment to be handled there. For example, DBISQL handles the
error by displaying a message window describing the error.

The TRACEBACK function provides a list of the statements that were
executing when the error occurred. You can use the TRACEBACK function
from DBISQL by typing the following statement:

SELECT TRACEBACK(*)

Advertising