PL supports two error-reporting functions: SQLCODE and SQLERRM, which can be used in PL's exception handling code. These functions can be used on exception handling code of PL.
Notice
The
SQLCODEandSQLERRMfunctions cannot be used in SQL statements.
SQLCODE function
In an exception handler, SQLCODE returns the error code corresponding to the exception being handled. Outside an exception handler, SQLCODE always returns 0.
For an internally defined exception, the numeric code is associated with the code of the database error.
For a user-defined exception, the numeric code is the default value +1 or the error code associated with an exception of the EXCEPTION_INIT compilation directive.
Syntax:
SQLCODE
SQLERRM function
SQLERRM returns the error message associated with an error code.
Syntax:
SQLERRM [ ( error_code ) ]
In the syntax, error_code is optional. If no error code is available, this function returns the error message corresponding to the current value of the SQLCODE function.