PLSQL - Difference between While and Loop


While Loop v/s Basic Loop

  • While loop will execute only when condition evaluates true

declare

x number;

Begin

x := 1;

while x > 15

Loop

dbms_output.put_line(x);

x := x + 1;

End Loop;

end;


Basic Loop

  • The loop gets executed at least one time.


Declare

x number;

Begin

x :=  1;

Loop

dbms_output.put_line(x);

exit when x = 1;

x := x + 1;

End Loop;

End;

Complete Tutorial

*/

No comments:

Post a Comment