Errors and messages v17
Reporting messages
Use the DBMS_OUTPUT.PUT_LINE
statement to report messages:
Where message
is any expression evaluating to a string.
This example displays the message on the user’s output display:
The special variables SQLCODE
and SQLERRM
contain a numeric code and a text message, respectively, that describe the outcome of the last SQL command issued. If any other error occurs in the program such as division by zero, these variables contain information pertaining to the error.
SQLCODE and SQLERRM functions
SQLCODE and SQLERRM functions are now available in EDB Postgres Advanced Server.
In an exception handler, the SQLCODE
function returns the numeric code of the exception being handled. Outside an exception handler, SQLCODE
returns 0
.
The SQLERRM
function, returns the error messaage associated with an SQLCODE
variable value. If the error code value is passed to the SQLERRM
function, it returns an error message associated with the passed error code value, regardless of the current error raised.
A SQL statement can't invoke SQLCODE
and SQLERRM
functions.
Examples:
- On this page
- Reporting messages
- SQLCODE and SQLERRM functions