09.01.2015 Views

PL/SQL User's Guide and Reference

PL/SQL User's Guide and Reference

PL/SQL User's Guide and Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>SQL</strong>ERRM Function<br />

<strong>SQL</strong>ERRM Function<br />

Syntax<br />

The function <strong>SQL</strong>ERRM returns the error message associated with its error-number<br />

argument or, if the argument is omitted, with the current value of <strong>SQL</strong>CODE.<br />

<strong>SQL</strong>ERRM with no argument is meaningful only in an exception h<strong>and</strong>ler. Outside a<br />

h<strong>and</strong>ler, <strong>SQL</strong>ERRM with no argument always returns the message normal, successful<br />

completion.<br />

For internal exceptions, <strong>SQL</strong>ERRM returns the message associated with the Oracle<br />

error that occurred. The message begins with the Oracle error code.<br />

For user-defined exceptions, <strong>SQL</strong>ERRM returns the message user-defined exception<br />

unless you used the pragma EXCEPTION_INIT to associate the exception with an<br />

Oracle error number, in which case <strong>SQL</strong>ERRM returns the corresponding error<br />

message. For more information, see "Retrieving the Error Code <strong>and</strong> Error Message:<br />

<strong>SQL</strong>CODE <strong>and</strong> <strong>SQL</strong>ERRM" on page 7-18.<br />

sqlerrm_function<br />

<strong>SQL</strong>ERRM<br />

( error_number )<br />

Keyword <strong>and</strong> Parameter Description<br />

error_number<br />

This must be a valid Oracle error number. For a list of Oracle errors, see Oracle9i<br />

Database Error Messages.<br />

Usage Notes<br />

<strong>SQL</strong>ERRM is especially useful in the OTHERS exception h<strong>and</strong>ler because it lets you<br />

identify which internal exception was raised.<br />

You can pass an error number to <strong>SQL</strong>ERRM, in which case <strong>SQL</strong>ERRM returns the<br />

message associated with that error number. The error number passed to <strong>SQL</strong>ERRM<br />

should be negative. Passing a zero to <strong>SQL</strong>ERRM always returns the following<br />

message:<br />

ORA-0000: normal, successful completion<br />

13-180 <strong>PL</strong>/<strong>SQL</strong> User’s <strong>Guide</strong> <strong>and</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!