Oracle中PL/SQL的循环语句
2009-07-08 09:28
405 查看
PL/SQL的三种形式的循环:
1.LOOP(无条件循环):
loop
statements;
end loop;
2.WHILE(有条件循环):
while condition loop
statements;
end loop;
3.FOR(固定次数循环):
for counter in value1 .. value2
loop
statements;
end loop;
实例:分别用三种循环输出1-100
loop:
view plaincopy to clipboardprint?
declare i number;
begin
i := 1;
loop
if i > 100 then
goto quit;
end if;
dbms_output.put_line(i);
i := i + 1;
end loop;
<<quit>>
null;
end;
while:
view plaincopy to clipboardprint?
declare
i number;
begin
i := 1;
while i<=100 loop
dbms_output.put_line(i);
i := i+1;
end loop;
end;
for:
view plaincopy to clipboardprint?
declare
i number;
begin
for i in 1..100
loop
dbms_output.put_line(i);
end loop;
end;
1.LOOP(无条件循环):
loop
statements;
end loop;
2.WHILE(有条件循环):
while condition loop
statements;
end loop;
3.FOR(固定次数循环):
for counter in value1 .. value2
loop
statements;
end loop;
实例:分别用三种循环输出1-100
loop:
view plaincopy to clipboardprint?
declare i number;
begin
i := 1;
loop
if i > 100 then
goto quit;
end if;
dbms_output.put_line(i);
i := i + 1;
end loop;
<<quit>>
null;
end;
declare i number; begin i := 1; loop if i > 100 then goto quit; end if; dbms_output.put_line(i); i := i + 1; end loop; <<quit>> null; end;
while:
view plaincopy to clipboardprint?
declare
i number;
begin
i := 1;
while i<=100 loop
dbms_output.put_line(i);
i := i+1;
end loop;
end;
declare i number; begin i := 1; while i<=100 loop dbms_output.put_line(i); i := i+1; end loop; end;
for:
view plaincopy to clipboardprint?
declare
i number;
begin
for i in 1..100
loop
dbms_output.put_line(i);
end loop;
end;
declare i number; begin for i in 1..100 loop dbms_output.put_line(i); end loop; end;
相关文章推荐
- Oracle PL/SQL之LOOP循环控制语句
- Oracle PL/SQL之LOOP循环控制语句
- Oracle PL/SQL之LOOP循环控制语句
- oracle PL/SQL的基本构成,结构控制语句,分支结构,选择结构,loop循环结构,
- Oracle PL/SQL之LOOP循环控制语句
- Oracle PL/SQL之LOOP循环控制语句
- Oracle PL/SQL之LOOP循环控制语句
- oracle pl/sql中的循环及if语句
- Oracle PL/SQL之LOOP循环控制语句
- [oracle]pl/sql --循环语句demo
- Oracle PL/SQL之LOOP循环控制语句
- Oracle PL/SQL 循环控制语句
- Oracle PL/SQL变量、常量、流程控制、循环语句
- Oracle PL/SQL之LOOP循环控制语句
- Oracle PL/SQL 找出100以内是3和5的倍数的数 循环语句
- Oracle PL/SQL之LOOP循环控制语句
- Oracle PL/SQL之LOOP循环控制语句
- Oracle PL/SQL 中循环语法语句的应用
- [oracle]pl/sql --循环语句demo
- Oracle [PL/SQL]中的循环语句