While Loop in PL/SQL
For While in PL/SQL
Set of instructions given to the compiler to execute set of statements until condition becomes false is called loops. The basic purpose of loop is code repetition that means same code repeated again and again. Here we discuss While loop in PLSQL
A while loop is used when a set of statements has to be executed as long as a condition is true, the While loop is used. The condition is decided at the beginning of each iteration and continues until the condition becomes false.
variable initialize while (condition) statements; end loop;
Must be follow below steps;
- Initialise a variable before the loop body.
- Increment the variable in the loop body.
While Loop in PLSQL
DECLARE i INTEGER := 1; BEGIN WHILE i <= 10 LOOP DBMS_OUTPUT.PUT_LINE(i); i := i+1; END LOOP; END;
1 2 3 4 5 6 7 8 9 10