Oracle数据中循环使用方法
1.while循环使用方法
CREATE OR REPLACE procedure p_while(v_i out integer )
as
i integer:=1;
begin
as
i integer:=1;
begin
while i<10 loop
i:=i+1;
i:=i+1;
end loop;
v_i:=i;
dbms_output.PUT_LINE(to_char(v_i));
exception
when others then
begin
null;
end;
exception
when others then
begin
null;
end;
end;
2. for 循环使用方法
CREATE OR REPLACE procedure p_for(v_i out integer)
as
i integer:=1;
begin
as
i integer:=1;
begin
for j in 1..9 loop
i:=i+1;
end loop;
i:=i+1;
end loop;
v_i:=i;
dbms_output.PUT_LINE(to_char(v_i));
exception
when others then
begin
null;
end;
end;
/
dbms_output.PUT_LINE(to_char(v_i));
exception
when others then
begin
null;
end;
end;
/
3.loop循环使用方法
CREATE OR REPLACE procedure p_loop(v_i out integer)
as
i integer:=0;
begin
as
i integer:=0;
begin
loop
i:=i+1;
if i>=10 then
exit;
end if;
end loop;
i:=i+1;
if i>=10 then
exit;
end if;
end loop;
v_i:=i;
dbms_output.PUT_LINE(to_char(v_i));
exception
when others then
begin
null;
end;
end;
/
dbms_output.PUT_LINE(to_char(v_i));
exception
when others then
begin
null;
end;
end;
/
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14285854/viewspace-683249/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/14285854/viewspace-683249/