存储器批量造数据

DROP PROCEDURE if EXISTS `p_insert_hrs_pg`;
DELIMITER ;;

CREATE  PROCEDURE `p_insert_hrs_pg`(COUNT INT UNSIGNED)
BEGIN
    DECLARE s INT UNSIGNED DEFAULT 1;
    DECLARE a INT UNSIGNED DEFAULT 1;
    DECLARE i_l_hrs_pg_cycle_id INT;
    DECLARE i_l_hrs_pg_cycle_detail_id INT;
    DECLARE i_l_num10 INT;
    DECLARE i_l_num100 INT;
    DECLARE i_l_num01 INT;
    DECLARE i_l_hrs_pg_exec_id INT;
    DECLARE i_l_num07 INT;
    DECLARE i_l_hrs_pg_rank_id INT;
    
    DECLARE i_l_hrs_pg_id INT;
    SET s = 1;
    WHILE a <= COUNT DO
        SELECT id INTO i_l_hrs_pg_cycle_id  FROM hrs_pg_cycle ORDER BY RAND() LIMIT 1;
        SELECT id INTO i_l_hrs_pg_cycle_detail_id  FROM hrs_pg_cycle_detail ORDER BY RAND() LIMIT 1;
        SELECT TRUNCATE(RAND()*10,0) INTO i_l_num10;
        SELECT TRUNCATE(RAND()* 100,0) INTO i_l_num100;
        SELECT TRUNCATE(RAND()* 10,0)%2 INTO i_l_num01;
        SELECT id INTO i_l_hrs_pg_exec_id  FROM hrs_pg_exec ORDER BY RAND() LIMIT 1;
        IF i_l_num10 > 7 THEN
           SELECT 7 INTO i_l_num07;
        ELSE
           SELECT i_l_num10 INTO i_l_num07; 
        END IF;
        
        INSERT INTO hrs_pg
                (id,
                badge,
                cycle_id,
                cycle_detail_id,
                sub_num,
                weight,
                finished_rate,
                is_assign,
                summary,
                exec_id,
                result,
                feedback_times,
                audit_badge,
                audit_status,
                audit_desc,
                audit_time,
                create_time,
                update_time,
                pg_employeeinfo_id,
                STATUS)
         SELECT s,'15112319',i_l_hrs_pg_cycle_id,i_l_hrs_pg_cycle_detail_id,i_l_num10,i_l_num100,i_l_num100,i_l_num01,
                'summary',i_l_hrs_pg_exec_id,3,5,'18052957',i_l_num07,'audit_desc',1,'1535512718','1535512719',59,1
           FROM DUAL;
        
        SELECT id INTO i_l_hrs_pg_id  FROM hrs_pg ORDER BY RAND() LIMIT 1;
        SELECT id INTO i_l_hrs_pg_rank_id  FROM hrs_pg_rank ORDER BY RAND() LIMIT 1;
        INSERT INTO `hrs_pg_sub`
                (`id`,
                `pg_id`,
                `name`,
                `rank_id`,
                `bottom`,
                `standard`,
                `challenge`,
                `finished`,
                `finished_rate`,
                `check_report`,
                `exec_id`,
                `exec_desc`,
                `unit`,
                `description`,
                `status`,
                `create_time`,
                `update_time`)
        SELECT s,s,'target_name',i_l_hrs_pg_rank_id,10,100,1000,i_l_num100,i_l_num100,i_l_num100,i_l_hrs_pg_exec_id,
               'exec_desc','美元','desc',1,'1535512718','1535512719'
          FROM DUAL;

        
        SET a= a+1;
        SET s= s+1;
    END WHILE;
    COMMIT;
END ;;
DELIMITER ;

 

你可能感兴趣的:(存储器批量造数据)