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

Term: EXIT

Definition:
The Oracle PL/SQL EXIT statement is used to skip the current block. It can be used to terminate loops or stop processing based on a condition you specify. When encountered, an EXIT statement forces a loop to complete immediately and unconditionally. Control is then passed to the next statement (if any).

Example Syntax:

EXIT [ condition ];


The condition can be an expression or a value. For example:

EXIT WHEN core_temperature > 100;

Or
EXIT WHEN total_distance = (25/5);



Example Usage:

The statement below OPENs a cursor C, iterates and fetches the result set, EXITs when the result set is not found, and then closes the cursor.

OPEN C;
LOOP
FETCH
C INTO L_VAR1, L_VAR2;
EXIT WHEN C%NOTFOUND;
---
---
END LOOP;
CLOSE C;


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