zoukankan      html  css  js  c++  java
  • 执行存储过程,批量插入随机数据

    drop procedure if exists u_head_and_low_pro;
    delimiter //
    create procedure u_head_and_low_pro()
    begin
      DECLARE n int DEFAULT 0;
        WHILE n < 1000 DO
            insert into activity(data_code, coupon_activity_number, coupon_activity_title, coupon_activity_category,
                                    coupon_activity_type, product_type, coupon_type, currency_type, full_amount,
                                    decrease_amount, total_amount, take_amount, untake_amount, used_amount, per_user_limit,
                                    effective_caculate_mode, begin_effective_time, end_effective_time,
                                    coupon_activity_status, remark, create_by, create_time, update_by, update_time,
                                    del_flag, lock_version)
    values (CONCAT('248681711918', LPAD((@i:=n + 1), 4, 0)), left (upper (replace(uuid(), '-', '')), 5),
            "活动", 2, 2, 2, 1, "HKD", 1000, 100, 1, 0, 1, 0, 1, 1, "2017-02-01 00:00:00",
            "2018-02-25 23:59:59", 1, "后台批量添加1000条数据", "system", now(), "system", now(), 0, 0);
                set n = n + 1;
      END WHILE;
      commit;
    end;;
    call u_head_and_low_pro();

    将查询结果批量插入另一张表

    insert into rule(data_code,coupon_activity_code,trip_type,  begin_departure_time,end_departure_time,departure_days,remark,create_by,create_time,update_by,update_time,
            del_flag,lock_version)
            
            select
            CONCAT('258681711911', LPAD((@i:=@i + 1), 4, 0)) AS data_code,
            couponActivity.data_code,
            '["1","2"]',"2017-12-01 00:00:00","2018-09-01 23:59:59",'["1","2","3","4","5","6","7"]',
            "后台批量添加1000条数据","system",now(),"system",now(),0,0
            from activity as couponActivity,(select @i:=0) as it 
  • 相关阅读:
    eclipse文件编辑器相关概念
    Oracle ROLLUP和CUBE 用法
    eclipse插件开发常用的选择器
    oracle多cpu并行查询
    MYECLISE6.5下CDT安装
    oracle SAMPLE 语法应用
    常用的gcc命令
    vbscript获取本机的ip地址和mac地址
    什么是Single Sign On
    eclipse插件开发中全局对象的获取
  • 原文地址:https://www.cnblogs.com/javallh/p/11845242.html
Copyright © 2011-2022 走看看