The PL/SQL WHILE LOOP statement will execute a block of code when a given condition is true. If the condition evaluates to TRUE, the block of code is executed, if condition evaluates to FALSE, the loop terminates and control is passed to the next executable statement following the END LOOP keywords.
Use PL/SQL WHILE LOOP when you don't know how many times the loop will execute. If you know in advanced number of time iterations, use the PL/SQL FOR LOOP statement instead.
To execute a block of code when a given condition is true, use the following syntax:
Let's understand how it works: