Quick Search:
 
 The Oracle EXCEPTION Function      [Return To Index] Jump to:  

Term: EXCEPTION

Definition:
In Oracle PL/SQL, an EXCEPTION refers to abnormal situation that occurs in the course of a program's flow. It is an optional section of a PL/SQL block or any other subprogram which can be used to capture and handle the exception that is raised from the PL/SQL execution block.

If an exception is raised inside the executable part of the PL/SQL block, program flow jumps to the EXCEPTION section which is searched for the appropriate exception handling code (if present). If the exception is handled a set of statements would be executed; otherwise exception propagates to the enclosing environment.

Example Usage:

The PL/SQL block below returns '1' if the employee exists, otherwise is raises the exception NO_DATA_FOUND.

BEGIN
SELECT 1
INTO L_EMP
FROM EMPLOYEE
WHERE EMPLOYEE_ID = 99999;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE ('Employee Id '||TO_CHAR('99999')||' does not exist');
END;


Related Links:

Related Code Snippets:
 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org