|PL/SQL User's Guide and Reference
Release 2 (9.2)
Part Number A96624-01
PL/SQL Language Elements, 38 of 52
RAISE statement stops normal execution of a PL/SQL block or subprogram and transfers control to the appropriate exception handler. Normally, predefined exceptions are raised implicitly by the runtime system. However,
RAISE statements can also raise predefined exceptions. User-defined exceptions must be raised explicitly by
RAISE statements. For more information, see "Defining Your Own PL/SQL Exceptions".
This identifies a predefined or user-defined exception. For a list of the predefined exceptions, see "Predefined PL/SQL Exceptions".
PL/SQL blocks and subprograms should
RAISE an exception only when an error makes it undesirable or impossible to continue processing. You can code a
RAISE statement for a given exception anywhere within the scope of that exception.
When an exception is raised, if PL/SQL cannot find a handler for it in the current block, the exception propagates. That is, the exception reproduces itself in successive enclosing blocks until a handler is found or there are no more blocks to search. In the latter case, PL/SQL returns an unhandled exception error to the host environment.
Omitting the exception name in a
RAISE statement, which is allowed only in an exception handler, reraises the current exception. When a parameterless
RAISE statement executes in an exception handler, the first block searched is the enclosing block, not the current block.
In the following example, you raise an exception when an inventoried part is out of stock: