RAISE_APPLICATION_ERROR allows you to abort processing in an SPL program by causing an exception. The exception is handled in the same manner as described in Exception handling. In addition, the
RAISE_APPLICATION_ERROR procedure makes a user-defined code and error message available to the program, which you can then use to identify the exception.
error_number is an integer value or expression returned in a variable named
SQLCODE when the procedure is executed. The value is between
message is a string literal or expression returned in a variable named
For more information on the
SQLERRM variables, see Errors and messages.
This example uses the
RAISE_APPLICATION_ERROR procedure to display a different code and message depending on the information missing from an employee:
The following shows the output in a case where the manager number is missing from an employee record: