while循环
while 条件 loop
循环体
end loop
declare
pnum number := 1;
begin
while pnum <= 10 loop
--循环体
dbms_output.put_line(pnum);
pnum := pnum + 1; --pl/sql中不能使用++
end loop;
end;
loop 循环
loop
exit[when 条件];
end loop
declare
pnum number := 1;
begin
loop
exit when pnum > 10;
dbms_output.put_line(pnum);
pnum := pnum + 1;
end loop;
end;
for循环
for i in 1..3 loop –连续循环区间
语句序列;
end loop;
declare
pnum number := 1;
begin
for pnum in 1 .. 10 loop
dbms_output.put_line(pnum);
end loop;
end;
建议使用loop循环