MySQL存儲過程中判斷形參是否為空null


直接看例子:

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);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM