How many Types of Loops are Available in PL SQL?

Loops:

Iteration is commonly known as Looping. With the ability to repeatedly perform the same set of operations until the specified condition is met, the repeated execution stops.

Type of loops are available in PL SQL:

There are three sets of Loops available in PL SQL. These are:
1. LOOP …END LOOP: This statement is used for executing a set of statements again and again. The statements are written within the LOOP …END LOOP is executed until an EXIT statement is encountered.

Example:


LOOP
CTR :=CTR+1;
IF CTR=10 THEN
EXIT;
ENDIF;
END LOOP;
The above examples can also be written as follows:

LOOP
CTR :=CTR+1;
EXIT WHEN CTR=10;
END LOOP;

2. FOR … LOOP: This loop is used in such cases where the statements within the loop must be carried out again and again over a specified number of times only.

3. WHILE … LOOP: The syntax for WHILE… LOOP is


WHILE  LOOP
END LOOP;