ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Oracle数据库中循环使用方法

Oracle数据库中循环使用方法

原创 Linux操作系统 作者:rockydq_wang 时间:2011-01-03 22:07:42 0 删除 编辑
                                                                  Oracle数据中循环使用方法
1.while循环使用方法
CREATE OR REPLACE procedure p_while(v_i out integer )
as
i integer:=1;
begin
while i<10 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;
 
2. for 循环使用方法
CREATE OR REPLACE procedure p_for(v_i out integer)
as
i integer:=1;
begin
for j in 1..9 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;
/
 
3.loop循环使用方法
 
CREATE OR REPLACE procedure p_loop(v_i out integer)
as
i integer:=0;
begin
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;
/
 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/14285854/viewspace-683249/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2010-12-27

  • 博文量
    3
  • 访问量
    27062