oracle中四種不同方法迴圈輸出1-10
阿新 • • 發佈:2019-01-27
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;