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

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      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 58 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?