declare
x number;
begin
x:=10; --定义的初始值
<<repeat_loop>> --循环点
x:= x-2; --循环的处理条件
dbms_output.put_line('结果x是:'||x); --循环一次打印一次
if x>0 then
GOTO repeat_loop; --再次循环
else if x<0 then
dbms_output.put_line('数值是x:'||x);
end if;
end if;
end;
2 Oracle中的for循环
declare
begin
for i in 2..10 Loop
dbms_output.put_line('结果i是:' || i);
end loop;
end;
3 Oracle中while的循环
declare
x number;
begin
x := 5;
while x>0 loop
x := x-1; --循环的每次处理
if x = 3 then
return; --跳出循环
else
dbms_output.put_line('x的值是'||x);
end if;
end loop;
end;
4 Oracle 中的loop循环
declare
x number;
begin
x:=0;
loop
x := x+1;
exit when x >5 ; -- x大于5时终止
dbms_output.put_line('结果x是two:' || x);
end loop;
end;