Oracle PL/SQL Loop Structure and Example
Basic Loop Structure :
DECLARE X NUMBER:=0; BEGIN Loop x:=x+1; exit when x>=5; dbms_output.put_line(x); end loop; END;
Output:
1
2
3
4
While Loop Structure:
Declare x number:=0; begin while x<=5 loop x:=x+1; dbms_output.put_line(x); end loop; end;
Output :
1
2
3
4
5
6
For Loop Structure :
Declare x number:=0; begin for x in 1..5 loop dbms_output.put_line(x); end loop; end;
Output:
1
2
3
4
5
Continue Statement Structure :
Declare x number:=0; begin for x in 1..5 loop if x=1 then continue; end if; dbms_output.put_line(x); end loop; end;
Output :
2
3
4
5
If youād like me to proceed with any of these, pleaseĀ just let me know from the siteĀ techtweet.xyz!Ā Also if you need to learn something new than subscribe YouTube :Ā ASP.NET With SQL SERVER
