Call (800) 766-1884 for Oracle support & training
Free Oracle Tips

Oracle Consulting Support
Oracle Upgrades
Use New Oracle Features
Oracle Replication Support
Oracle Training
Remote Oracle DBA
System Documentation
Oracle Tips
Oracle Performance

Free Oracle Tips



BC Oracle tuning

Oracle training

Oracle support

Remote Oracle




User-Defined Exceptions
Oracle Tips by Burleson

PL/SQL allows developers to define their own exceptions. This is a useful method of returning a specific status to calling procedures and functions. Giving user-defined exceptions meaningful names helps make code easier to understand. User-defined exceptions must be explicitly raised through the use of the RAISE statement. Listing 2.16 illustrates how user-defined exceptions are declared and raised.

Listing 2.16 A user-defined exception.

   xStudentNotEligibleForAid    EXCEPTION;
IF <condition> THEN
   RAISE xStudentNotEligibleForAid;

An exception raised using the RAISE statement is processed just like any exception raised by Oracle.

The OTHERS Exception Handler

The OTHERS exception handler functions as a catch-all exception handler for a PL/SQL block. The OTHERS exception handler is used as follows:

     System_Error_Handler (<parameters>);

Care must be taken when raising user-defined exceptions in a block that uses the OTHERS exception handler. If the user-defined exception is to be raised to a calling procedure, an exception handler for the user-defined exception should be defined that explicitly re-raises the exception, as follows:

   WHEN StudentNotEligibleForAid THEN
        System_Error_Handler (<parameters>);

The OTHERS exception handler should follow any other exception handlers. Any exception not handled by another exception handler is handled by the OTHERS exception handler.


This is an excerpt from the book "High Performance Oracle Database Automation" by Jonathan Ingram and Donald K. Burleson, Series Editor.


Oracle performance tuning software 

Oracle performance tuning book


Oracle performance Tuning 10g reference poster
Oracle training in Linux commands
Oracle training Excel
Oracle training & performance tuning books



Copyright © 1996 -  2014 by Burleson. All rights reserved.

Oracle® is the registered trademark of Oracle Corporation. 

Hit Counter