oracle循环语句 loop while for

   测试用表

create table hadoop_param(
name varchar2(255),
num int
)

 

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 := '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;
 for v_pos in 1..1000 loop
      v_name := 'name' || v_pos;
      v_num := v_pos;
      insert into hadoop_param values(v_name,v_num); 
 end loop;
 commit;
end;