首页 > 代码库 > 练习六 向表A批量插入数据

练习六 向表A批量插入数据

create or replace procedure BATCH_INSERT_A(insertNo in integer) isn_id integer;/***************************name:batch_insert_table_ppurpose:--向A表批量插入数据imput:--批量插入数据的数据量output:n/aauthor:cicicreatedate:updatedate:***************************/begin      SELECT MAX(ID) into n_id from a;      if n_id is null then                     n_id:=0;      end if;//begin for loopfor i in n_id+1...n_id+insertNo loop           dbms_output.put_line(‘NO is‘||i||‘NOW‘);           dbms_output.put_line(‘Name is ‘||‘a‘||i||‘NOW‘);           INSERT INTO                     A(name,id) values(‘a‘||i,i);           end loop;end BATCH_INSERT_A;

 

/*另一种写法 declare   v_num number;begin        v_num:=1;       while v_num!=20 loop            insert into A(id,name)            values(a_seq.nextval,‘a4‘);          v_num:=v_num+1;       end loop;end; */

 

练习六 向表A批量插入数据