Database Reference
In-Depth Information
CASE num2
WHEN 0 THEN
DBMS_OUTPUT.PUT_LINE (num||' is an even number'); ELSE
DBMS_OUTPUT.PUT_LINE (num||' is an odd number'); END CASE;
DBMS_OUTPUT.PUT_LINE ('Good Bye');
END;
8.8 Looping using PL/SQL
When a statement or group of statements is executed several times, is called looping. In
PL/SQL, there are four types of loops simple loops, WHILE loops, numeric FOR loops,
and cursor FOR loops. While there are differences among the three loop constructs, every
loop has two parts: the loop boundary and the loop body:
Loop boundary: This is composed of the reserved words that initiate the loop, the condition
that causes the loop to terminate, and the END LOOP statement that ends the loop.
Loop body: This is the sequence of executable statements inside the loop boundary that ex-
ecute on each iteration of the loop.
8.8.1 Simple (Infinite) Loop
This loop has simplest loop structure. This is also called an infinite loop. It has the follow-
ing syntax:
LOOP
statement 1;
statement 2;
................
………….
statement n;
END LOOP;
The EXIT statement is used to terminate a loop when the EXIT condition evaluates to
TRUE. An IF statement is used to evaluated EXIT condition. No it will not be an infinite
loop. It has the following syntax:
LOOP
Statement1;
Statement2;
Search WWH ::




Custom Search