码迷,mamicode.com
首页 > 数据库 > 详细

MySQL存储过程中判断形参是否为空null

时间:2015-05-04 11:49:38      阅读:571      评论:0      收藏:0      [点我收藏+]

标签:

直接看例子:

DELIMITER $$
CREATE DEFINER=`root`@`127.0.0.1` PROCEDURE `restore`(username varchar(50))
BEGIN
if username is not null then
    update user set invalid=0 and activate_time=‘0000-00-00 00:00:00‘ where `name`=username;
else
    update user set invalid=0 and activate_time=‘0000-00-00 00:00:00‘;
end if;
END$$
DELIMITER ;

调用:

1. call restore(‘abc‘);

   or call restore(null);

 

MySQL存储过程中判断形参是否为空null

标签:

原文地址:http://www.cnblogs.com/tommy-huang/p/4475680.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!