作者:Mr尘世美_925 | 来源:互联网 | 2023-09-14 11:58
篇首语:本文由编程笔记#小编为大家整理,主要介绍了mysql 新建存储过程中容易出错的地方相关的知识,希望对你有一定的参考价值。
DELIMITER $$
USE `tongliaograin`$$
DROP PROCEDURE IF EXISTS `A_Sys_GetAdminValidate`$$
CREATE DEFINER=`root`@`%` PROCEDURE `A_Sys_GetAdminValidate`(IN `sLoginName` VARCHAR(100),IN `sPassword` VARCHAR(100),IN `sIP` VARCHAR(100))
BEGIN
DECLARE nNum INT DEFAULT 0;
DECLARE nAdminID INT DEFAULT 0;
DECLARE slogcontent VARCHAR(100) DEFAULT "";
SELECT * FROM sys_admin WHERE LoginName = sLoginName AND `password`=sPassword;
SELECT COUNT(*) INTO nNum FROM sys_admin WHERE LoginName = sLoginName AND `password`=sPassword;
IF(nNum > 0) THEN
SELECT CAST(AdminID AS SIGNED) INTO nAdminID FROM sys_admin WHERE LoginName = sLoginName AND `password`=sPassword;
SET slogcontent = CONCAT(‘【用户登录】后台用户:‘,sLoginName,‘IP地址为:‘,sIP,‘ 登录成功‘);
CALL A_SysLog_Add(12,nAdminID,slogcontent);
END IF;
END$$
DELIMITER ;
1、开头和结尾需要用到 DELIMITER $$ 和 DELIMITER ;
2、存储过程参数,必须有in out inout ,参数名必须用 “·”符号包起来,而且必须声明参数类型及其长度