作者:diy2099_d94639 | 来源:互联网 | 2014-07-09 16:02
oracle语法备忘之循环oracle循环语句loopwhilefor测试用表Sql代码createtablehadoop_param(namevarchar2(255),numint)www.2cto.comSql代码declarev_namevarchar2(255);v_nu...
oracle语法备忘之循环
oracle循环语句 loop while for
测试用表
Sql代码
create table hadoop_param(
name varchar2(255),
num int
)
www.2cto.com
Sql代码
declare
v_name varchar2(255);
v_num int;
v_pos int;
begin
v_pos:=0;
loop
exit when v_pos = 1000;
v_pos := v_pos+1;
v_name := 'name' || v_pos;
v_num := v_pos;
insert into hadoop_param values(v_name,v_num);
end loop;
commit;
end;
declare
v_name varchar2(255);
v_num int;
v_pos int;
begin
v_pos := 1;
while v_pos <= 1000 loop
v_pos := v_pos +1;
v_name := &#39;name&#39; || v_pos;
v_num := v_pos;
insert into hadoop_param values(v_name,v_num);
end loop;
commit;
end;
declare
v_name varchar2(255);
v_num int;
v_pos int;
begin
v_pos := 1;
for v_pos in 1..1000 loop
v_name := &#39;name&#39; || v_pos;
v_num := v_pos;
insert into hadoop_param values(v_name,v_num);
end loop;
commit;
end;