oracle 批量导入数据

create or replace procedure insert_sns_user
 is
  n Number;
     i int;
begin
 i:=9781000001;
   while i<=9781000005 loop
    select count(1) into n from h_rcs_user h where h.rcs_userid=''||i||'';
   if n=0 then
         insert into h_rcs_user(ID,rcs_token,rcs_userid,rcs_username,rcs_mobile,status,createtime) values(huawei_sequence.NEXTVAL,null,i,null,'+7'||i,0,sysdate);
   end if;        
 i:=i+1;
commit;
end loop;
end insert_sns_user;

 执行

   begin
        -- Call the procedure
        insert_sns_user;
      end; 			
 
create or replace procedure insert_sns_user_bind
 is
  n Number;
     i int;
begin
 i:=9781000001;
   while i<=9781000005 loop
    select count(1) into n from h_rcs_user_binded h where h.userid=''||i||'';
   if n=0 then
         insert into h_rcs_user_binded(ID,userid,sns,appid,access_token,createtime,validtime,sns_userid,sns_name,sns_url,access_secret) values
         (SEQ_SNS_USER_BINDED.NEXTVAL,''||i,'facebook',55,'AAABy25AW8JkBAAt7tZAsZBcb48ZApcCgcoZBpuB7S7nHaiRGhGj2HRjU',sysdate,0,'1471613808','testUser','http://www.facebook.com/testUser','wMD3w8c3XQLvbtcEiCMMwR3If7Bbzz1jCYUS0mhHNc');
   end if;
 i:=i+1;
commit;
end loop;
end insert_sns_user_bind;

猜你喜欢

转载自jakbb.iteye.com/blog/1540175