• Skip to primary navigation
  • Skip to main content

Tech Honey

The #1 Website for Oracle PL/SQL, OA Framework and HTML

  • Home
  • HTML
    • Tags in HTML
    • HTML Attributes
  • OA Framework
    • Item in OAF
    • Regions in OAF
    • General OAF Topics
  • Oracle
    • statement
    • function
    • clause
    • plsql
    • sql
You are here: Home / Oracle / loop / Loop Statement in Oracle PLSQL

Loop Statement in Oracle PLSQL

November 23, 2012 by techhoneyadmin

A Loop in Oracle PLSQL is used to execute a portion of code i.e. the body of loop until a specific (exit) condition is not met.

In other words, we can say that we use the LOOP statement in Oracle PLSQL when we are not sure as to how many times the loop’s body should execute and we want the loop’s body to get executed at least once.
A LOOP gets terminated when it encounters an EXIT or EXIT WHEN statement which evaluates to true.

The Syntax for the LOOP Statement in Oracle PLSQL is:
LOOP
{
Statements to be executed;
}
END LOOP;

Example of a LOOP Statement in Oracle PLSQL is:

LOOP
{
  sum := sum + 1;
  EXIT WHEN sum = 35;
}
END LOOP;

The above loop will execute the “sum := sum+1; statement 35 times. The loop will start counting from 1 and as soon as the value of the “sum” variable crosses above 35 the loop will terminate.


Filed Under: loop Tagged With: how to use LOOP Statement in oracle database query, how to use LOOP Statement in oracle plsql, how to use LOOP Statement in oracle sql, LOOP Statement in oracle plsql, LOOP Statement in oracle sql, LOOPSTATEMENTPLSQL, syntax and example of LOOP Statement in oracle database query, syntax and example of LOOP Statement in oracle plsql, syntax and example of LOOP Statement in oracle sql, using LOOP Statement in oracle database query, using LOOP Statement in oracle plsql, using LOOP Statement in oracle sql

Copyright © 2023 · Parallax Pro on Genesis Framework · WordPress · Log in