fastread homefastrread library fastread menu

Oracle/PLSQL : REPEAT UNTIL LOOP

Tutorial by:      Date: 2016-04-15 05:12:36

❰ Previous Next ❱

This Oracle tutorial explains how to use the REPEAT UNTIL LOOP in Oracle with syntax and examples.

Description

Oracle doesn't have a REPEAT UNTIL LOOP, but you can emulate one with a LOOP statement.

Syntax

The syntax for emulating a REPEAT UNTIL LOOP in Oracle/PLSQL is:

LOOP

   {...statements...}

   EXIT [ WHEN boolean_condition ];

END LOOP;

Parameters or Arguments

statements
The statements of code to execute each pass through the loop.
boolean_condition
Optional. It is the condition to terminate the loop.

Note

  • You would use an emulated REPEAT UNTIL LOOP when you do not know how many times you want the loop body to execute.
  • The REPEAT UNTIL LOOP would terminate when a certain condition was met.

Example

Let's look at an example of how to emulate a REPEAT UNTIL LOOP in Oracle/PLSQL:

LOOP
   monthly_value := daily_value * 31;
   EXIT WHEN monthly_value > 4000;
END LOOP;

In this example, we want the loop to repeat until monthly_value is greater than 4000, so we use the EXIT WHEN statement.

EXIT WHEN monthly_value > 4000;

Now, the LOOP would repeat until the monthly_value exceeded 4000.

❰ Previous Next ❱


Oracle/PLSQL

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website