您的位置:首页 > 数据库 > Oracle

oracle中四种不同方法循环输出1-10

2010-08-05 08:54 267 查看
set serveroutput on

declare

i int:=10;

j int:=0;

begin

loop

j:=j+1;

if j<11 then

dbms_output.put_line(j);

elsif j>11 then

exit;

end if;

end loop;

end;

set serveroutput on

declare

i int:=11;

j int:=0;

begin

for j in 1..i loop

if j<11 then

dbms_output.put_line(j);

elsif j>11 then

exit;

end if;

end loop;

end;

set serveroutput on

declare

i int:=11;

j int:=1;

begin

while j<11 loop

dbms_output.put_line(j);

j:=j+1;

end loop;

end;

set serveroutput on

declare

i int:=11;

j int:=1;

begin

loop

exit when j>10 ;

dbms_output.put_line(j);

j:=j+1;

end loop;

end;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: