1. 单循环
create or replace function perfunctory_test(x in number)
return number is z number;
begin
loop
z:=x*x+2*x+1; --实现函数(x+1)的平方
exit;
end loop;
return z;
end;
2. for循环
create or replace function for_test(x in number)
return number is
z number;
begin
z:=0;
for v_sum in 1..50
loop
z:=z+2;
end loop;
return z; --结果为100
end for_test;
3. while循环
create or replace function while_test(x in number)
return number is z number;
begin
z:=0;
while z<100
loop
z:=z+2;
end loop;
return z; --结果为100
end;