Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle PL/SQL SQLERRM Function      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: SQLERRM

Definition:
In Oracle PL/SQL, SQLERRM is an error trapping function which returns the predefined error message corresponding to the input error number argument. If no argument has been provided, SQLERRM returns the error message associated with the last standard exception raised by the Oracle Server. It is defined in the Oracle STANDARD package.

For user defined exceptions, SQLERRM returns the error message defined for an error number in PRAGMA EXCEPTION_INIT.

If SQLERRM is invoked in the execution portion of the block, it returns "ORA-0000: normal, successful completion".

Example Syntax:

SQLERRM(Error Number)


Example Usage:

The PL/SQL block below raises ZERO_DIVIDE exception and displays the error message corresponding to error number -01476.

DECLARE
L_NUM1 NUMBER;
L_NUM2 NUMBER;
BEGIN
L_NUM1 := 10;
L_NUM2 := 0;
DBMS_OUTPUT.PUT_LINE('RESULT:'||L_NUM1/L_NUM2);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Exception Message:'||SQLERRM);
END;
/

Exception Message:ORA-01476: divisor is equal to zero

PL/SQL procedure successfully completed.


Related Links:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 117 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?