mysql sp
2015-12-28 15:39
459 查看
drop procedure if exists p_update_platform;
delimiter $$
create procedure p_update_platform(in p_platform_id int,in p_platform_name varchar(50),in p_shop_id int,out p_num int)
begin
set p_num=1;
WHILE
exists(select 1 from sale_order where shop_id=p_shop_id and platform_id is null)
and p_num<=10
do
update sale_order set platform_id=p_platform_id,platform_name=p_platform_name where shop_id=p_shop_id and platform_id is null limit 1;
set p_num=p_num+1;
end while ;
end ;
$$
delimiter ;
set @platform_id=1010,@platform_name='天猫',@shop_id=35;
call p_update_platform(1010,'天猫', 35,@p_num);
select @p_num;
delimiter $$
create procedure p_update_platform(in p_platform_id int,in p_platform_name varchar(50),in p_shop_id int,out p_num int)
begin
set p_num=1;
WHILE
exists(select 1 from sale_order where shop_id=p_shop_id and platform_id is null)
and p_num<=10
do
update sale_order set platform_id=p_platform_id,platform_name=p_platform_name where shop_id=p_shop_id and platform_id is null limit 1;
set p_num=p_num+1;
end while ;
end ;
$$
delimiter ;
set @platform_id=1010,@platform_name='天猫',@shop_id=35;
call p_update_platform(1010,'天猫', 35,@p_num);
select @p_num;
相关文章推荐
- DOS执行mysql数据库备份及压缩
- mysql事务锁等待时间
- MySQL Fabric实验(一)HA
- mysql 内连接、左连接、右连接
- mysql查询上一条和下一条信息
- mysql常见命令
- mysqldump使用
- mysql个人笔记
- mysql报错1872: Slave failed to initialize relay log info structure from the repository
- mysql报错解决MySQL Binlog(异常)——mysqlbinlog: unknown variable 'default-character-set=utf8'
- MySQL 5.7 传统复制到GTID在线切换
- Windows下更改MySQL数据库的存储位置
- MySQL 分区表
- MySQL 分区表
- mysql 数据库记录
- MSSQL迁移到MYSQL
- EF for Mysql
- mysql 索引
- MySQL运行状态show status中文详解
- MySQL中函数CONCAT及GROUP_CONCAT