• phpmyadmin创建mysql的存储过程


    DELIMITER $$
    CREATE  PROCEDURE `sp_insert_test_users`(IN `para_count` INT)
    BEGIN
        DECLARE p_username varchar(50);
        DECLARE p_countryCallingCode varchar(10) default '86';
        DECLARE p_phone varchar(20);
        DECLARE p_all_phone varchar(20);
        DECLARE p_create_time datetime;    
        DECLARE p_index int default 0;
        DECLARE p_userid int default 0;  
    IF para_count > 0 THEN
        SET p_create_time = NOW();
       
        while p_index < para_count do    
            
            select concat(
                  substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ', rand()*26 , 1),
                  substring('abcdefghijklmnopqrstuvwxyz', rand()*26 , 1),
                  substring('abcdefghijklmnopqrstuvwxyz', rand()*26 , 1),
                  substring('abcdefghijklmnopqrstuvwxyz', rand()*26 , 1),
                  substring('abcdefghijklmnopqrstuvwxyz', rand()*26 , 1),
                  substring('abcdefghijklmnopqrstuvwxyz', rand()*26 , 1),
                  substring('abcdefghijklmnopqrstuvwxyz', rand()*26 , 1),
                  substring('abcdefghijklmnopqrstuvwxyz', rand()*26 , 1)
                 ) into p_username;
                 
            select concat(
                  '139',
                  substring('1234567890', rand()* 10 , 1),
                  substring('1234567890', rand()* 10 , 1),
                  substring('1234567890', rand()* 10 , 1),
                  substring('1234567890', rand()* 10 , 1),
                  substring('1234567890', rand()* 10 , 1),
                  substring('1234567890', rand()* 10 , 1),
                  substring('1234567890', rand()* 10 , 1),
                  substring('1234567890', rand()* 10 , 1)
                 ) into p_phone;
            
            if not exists ( select 1 from users where username = p_username or phone = p_phone ) 
            and length(p_username) = 8 and length(p_phone) = 11
            then 
            
                set p_all_phone = concat(p_countryCallingCode,';',p_phone);
                
                INSERT INTO `users`
                (`username`, `countryCallingCode`, `phone`, `_phone`, 
                `group`,  `created_at`, `updated_at`) 
                VALUES 
                (p_username,p_countryCallingCode,p_phone,p_all_phone,
                'user', p_create_time, p_create_time);
                
                 select @@IDENTITY into p_userid;
                
                INSERT INTO `users_test_mock`
                (`userid`,`username`, `countryCallingCode`, `phone`) 
                VALUES 
                (p_userid,p_username,p_countryCallingCode,p_phone);
                
                SET p_index = p_index + 1;
                
            end if;
        
        
        end while;
       
            
    END IF;
    
    END$$
    DELIMITER ;
  • 相关阅读:
    实现MAXIMO7.5工作流任务箱任务颜色提示功能
    MAXIMO 快速查找实现
    DELPHI 通过方法名执行方法
    MAXIMO收件箱中,检修路线修改为其它名称
    在Linux 上手工创建 oracle 11g R2 数据库
    解决 maximo7.X 设备树子节点显示不全
    C++转换构造函数和隐式转换函数
    类或者结构体用无参构造函数创建对象时不需要带括号, 否则会当成函数声明
    今天我注册自己的博客啦,吼吼吼。。
    css3学习
  • 原文地址:https://www.cnblogs.com/jthb/p/14733287.html
Copyright © 2020-2023  润新知