drop procedure if exists p_for_create_customer;

create procedure p_for_create_customer()
begin
declare ii int default 0;
declare i int default 1;
declare minss int default 0;
declare idd int;
declare start_d datetime;
declare channel_code_ VARCHAR(255);
declare end_d datetime;
declare minutes int;
select id,countt,start_date,end_date,channel_code into idd,ii,start_d,end_d,channel_code_ from schedu_create_info where is_effective='true' limit 1;
select timestampdiff(minute,start_d,end_d) into minss from dual;
select idd from dual;
loop_example : loop
update schedu_create_info set is_effective='true' where id = idd;
set i = i + 1;
insert into crm_t_customer (mobile ,name ,idcard,channel_code,create_date)
value(CONCAT('1*********',rand_num(0,9)),'***','***',channel_code_,DATE_ADD(start_d,INTERVAL rand_num(0,minss) MINUTE) );
if i >ii then
leave loop_example;
end if;
end loop;
end;

call p_for_create_customer();

drop procedure if exists p_for_create_customer;

create procedure p_for_create_customer()
begin
declare ii int default 0;
declare i int default 1;
declare minss int default 0;
declare idd int;
declare start_d datetime;
declare channel_code_ VARCHAR(255);
declare end_d datetime;
declare minutes int;
select id,countt,start_date,end_date,channel_code into idd,ii,start_d,end_d,channel_code_ from schedu_create_info where is_effective='true' limit 1;
select timestampdiff(minute,start_d,end_d) into minss from dual;
select idd from dual;
loop_example : loop
update schedu_create_info set is_effective='false' where id = idd;
set i = i + 1;
insert into crm_t_customer (mobile ,name ,idcard,channel_code,create_date)
value(CONCAT('1*********',rand_num(0,9)),'***','***',channel_code_,DATE_ADD(start_d,INTERVAL rand_num(0,minss) MINUTE) );
if i >ii then
leave loop_example;
end if;
end loop;
end;

call p_for_create_customer();

delete from crm_t_customer;
select * from schedu_create_info;
select * from crm_t_customer;
call p_for_create_customer();

select rand_num(2,54);

alter event event_task_customer ON COMPLETION PRESERVE ENABLE;
alter event event_task_customer ON COMPLETION PRESERVE DISABLE;
DROP EVENT event_task_customer;

create event event_task_customer
on schedule every 2 minute
on completion PRESERVE
do call p_for_create_customer();

mysql存储过程实例,查询多参数赋值的更多相关文章

  1. MySql 存储过程实例 - 转载

    MySql 存储过程实例 将下面的语句复制粘贴可以一次性执行完,我已经测试过,没有问题! MySql存储过程简单实例:                                          ...

  2. MySql 存储过程实例(附完整注释)(转)

    MySql 存储过程实例(附完整注释) 将下面的语句复制粘贴可以一次性执行完,我已经测试过,没有问题! MySql存储过程简单实例:                                   ...

  3. PHP调用MYSQL存储过程实例

    PHP调用MYSQL存储过程实例 标签: mysql存储phpsqlquerycmd 2010-09-26 11:10 11552人阅读 评论(3) 收藏 举报 实例一:无参的存储过程$conn = ...

  4. 调用MYSQL存储过程实例

    PHP调用MYSQL存储过程实例 http://blog.csdn.net/ewing333/article/details/5906887 http://www.cnblogs.com/kkchen ...

  5. MySql 存储过程实例(附完整注释)

    将下面的语句复制粘贴可以一次性执行完,我已经测试过,没有问题! MySql存储过程简单实例:                                                       ...

  6. MySQL 存储过程实例 与 ibatis/mybatis/hibernate/jdbc 如何调用存储过程

    虽然MySQL的存储过程,一般情况下,是不会使用到的,但是在一些特殊场景中,还是有需求的.最近遇到一个sql server向mysql迁移的项目,有一些sql server的存储过程需要向mysql迁 ...

  7. mysql 存储过程实例

    --存储过程名和参数,参数中in表示传入参数,out标示传出参数,inout表示传入传出参数 create procedure p_procedurecode(in sumdate varchar(1 ...

  8. MySQL存储过程实例

    一.创建MySQL数据库函数 TCC:无参数,查询fruit表中的所有数据 : TAA:两个参数,查询fruit总共有多少行:查询ids为某个值时水果表的数据 TDD:两个参数,查询ids不等于某个值 ...

  9. Mysql 存储过程实例详解

    存储过程和函数是事先经过编译并存储在数据库中的一段SQL语句的集合,存储和和函数的区别在于函数必须有返回值,而存储过程没有,存储过程的参数可以使用IN.OUT.INOUT类型,而函数的参数只能是IN类 ...

随机推荐

  1. mySql版本的相关问题:com.mysql.cj.jdbc.Driver和com.mysql.jdbc.Driver

    Mysql版本的相关问题:com.mysql.cj.jdbc.Driver和com.mysql.jdbc.Driver 1. 在使用mysql时,控制台日志报错如下: Loading class `c ...

  2. hdu 2091空心三角形

    把一个字符三角形掏空,就能节省材料成本,减轻重量,但关键是为了追求另一种视觉效果.在设计的过程中,需要给出各种花纹的材料和大小尺寸的三角形样板,通过电脑临时做出来,以便看看效果.  Input每行包含 ...

  3. SORT--不要仅限于题目中

    输入n,m 表示输入n个数输出前m个最大的数 Input The input file contains many test cases. Each case has 2 lines. The fir ...

  4. Codeforces 920F - SUM and REPLACE 【线段树】

    <题目链接> 题目大意: 给你一个序列,有两个操作,一个是求区间 l - r 的和,另一个是对区间l-r的元素修改值,x=d(x),d(x)为x的因子个数. 解题分析: 因为可能有多次修改 ...

  5. javascript基础的查缺补漏

    对象转基本类型 let a = { valueOf() { return 0; }, toString() { return '1'; }, [Symbol.toPrimitive]() { retu ...

  6. python核心语法

    一.语句和语法 #:注释 \:转译回车,继续上一行,在一行语句较长的情况下可以使用其来切分成多行,因其可读性差所以不建议使用 ::将两个语句连接到一行,可读性差,不建议使用 ::将代码的头和体分开 语 ...

  7. XamarinSQLite教程Xamarin.Android项目添加引用

    XamarinSQLite教程Xamarin.Android项目添加引用 在Xamarin.Android项目中,导入System.Data和Mono.Data.SQLite库的操作步骤如下: (1) ...

  8. Android应用源码 概览

    之前我讲过关于Android应用源码的使用,不要走弯路,没有用的源码不要深究. 记住目录就好. 这里还有很多源码, Javaapk这个网站里的.还有很多. 这些源码 有可能有用. 但是不必故意用它. ...

  9. Codeforces.487C.Prefix Product Sequence(构造)

    题目链接 \(Description\) 对于一个序列\(a_i\),定义其前缀积序列为\(a_1\ \mathbb{mod}\ n,\ (a_1a_2)\ \mathbb{mod}\ n,...,( ...

  10. AGC 027B.Garbage Collector(贪心)

    题目链接 \(Description\) 坐标轴正半轴上有\(n\)个垃圾,位置分别是\(x_i\).在原点处有一个垃圾桶.一个机器人要从原点出发,将所有垃圾带到垃圾桶(原点)处. 机器人可以在坐标轴 ...