declare批量插入数据


declare
  v_id         varchar(32);
  v_i          number;
  v_name       varchar(12);
  v_sex        varchar(2);
  v_x          number;
  v_telphone1  number;
  v_telphone2  number;
  v_telphone3  number;
  v_y          number;
  v_rank       varchar(20);
  v_agentno    varchar(20);
  v_z          number;
  v_j          number;
  v_k          number;
  v_list_type1 varchar(10);
  v_list_type2 varchar(10);
  v_list_type3 varchar(10);
begin
  v_i := 1;

  while (v_i < 10) loop
    v_id         := sys_guid();
    v_name       := '左龙龙' || v_i;
    v_list_type1 := 'type' || v_z;
    v_list_type2 := 'type' || v_j;
    v_list_type3 := 'type' || v_k;
    select round(dbms_random.value(0, 1)) into v_x from dual;
    select round(dbms_random.value(10000000000, 19999999999))
      into v_telphone1
      from dual;
    select round(dbms_random.value(10000000000, 19999999999))
      into v_telphone2
      from dual;
    select round(dbms_random.value(10000000000, 19999999999))
      into v_telphone3
      from dual;
    select round(dbms_random.value(0, 9)) into v_y from dual;
    select round(dbms_random.value(1000000000, 1999999999))    into v_agentno    from dual;
     select a.agentno into v_agentno
   from c_chnl_agent_info a
   where not exists (
         select 0 from umap_sale_customer_info b where a.agentno = b.agentno
   )
   and a.business = 'LBS'
   and rownum =1;  
   
    select round(dbms_random.value(0, 9)) into v_z from dual;
    select round(dbms_random.value(0, 9)) into v_j from dual;
    select round(dbms_random.value(0, 9)) into v_k from dual;
    if (v_x = 0) then
      v_sex := 'F';
    else
      v_sex := 'M';
    end if;
    if (v_y = 0) then
      v_rank := '高级业务主任';
    elsif (v_y = 1) then
      v_rank := '展业课科长';
    elsif (v_y = 2) then
      v_rank := '行销主任';
    elsif (v_y = 3) then
      v_rank := '试用业务员';
    elsif (v_y = 4) then
      v_rank := '行销经理';
    elsif (v_y = 5) then
      v_rank := '试用收展员';
    elsif (v_y = 6) then
      v_rank := '资深业务主任';
    elsif (v_y = 7) then
      v_rank := '展业处经理';
    elsif (v_y = 8) then
      v_rank := '区部经理';
    else
      v_rank := 'FNA业务员';
    end if;
    insert into umap_sale_customer_info
      (ID_UMAP_SALE_CUSTOMER_INFO,
       CUSTOMER_NAME,
       CUSTOMER_SEX,
       CUSTOMER_PHONENUM1,
       CUSTOMER_PHONENUM2,
       CUSTOMER_FIXEDLINENUM,
       rank,
      AGENTNO,
       LIST_TYPE_ONE,
       LIST_TYPE_TWO,
       LIST_TYPE_THREE,
       SYNC_STATUS,CREATED_DATE)
    values
      (v_id,
       v_name,
       v_sex,
       v_telphone1,
       v_telphone2,
       v_telphone3,
       v_rank,
       v_agentno,
       v_list_type1,
       v_list_type2,
       v_list_type3,
       '0',sysdate);
    insert into umap_sale_task
      (ID_UMAP_SALE_TASK,
       TASK_CODE,
       CUSTOMER_ID,
       CURRENT_HANDLER_UM,
       CREATED_BY,
       CREATED_DATE,
       UPDATED_BY,
       UPDATED_DATE,status,ACTIVATE_STATUS)
    values
      (sys_guid(),
       sys_guid(),
       v_id,
       'SONGBO001',
       v_name,
       sysdate,
       v_name,
       sysdate,'1','1');
       v_i:=v_i+1;
  end loop;
end;

select * from umap_sale_customer_info i where i.created_date > sysdate -1/24;

update umap_sale_customer_info i set i.sync_status = '0' where i.created_date > sysdate -1/24

猜你喜欢

转载自my.oschina.net/u/2356637/blog/1517422