求助MySql创建存储过程错误
DELIMITER$$CREATEPROCEDUREGetJinCaiData(INdatatimeDATETIME,INjctypeVARCHAR(100))BEGIN...
DELIMITER $$CREATE PROCEDURE GetJinCaiData(IN datatime DATETIME,IN jctype VARCHAR(100))BEGIN DECLARE @maxdate DATETIME DEFAULT '1900-01-01 00:00:00'; DECLARE @mindate DATETIME DEFAULT '1900-01-01 00:00:00'; DECLARE @datatime DATETIME DEFAULT '1900-01-01 00:00:00'; DECLARE @jctype VARCHAR DEFAULT ''; SET @datatime = datatime; SET @jctype = jctype; SELECT MIN(createdatetime) INTO @mindate FROM lotterydata WHERE createdatetime >= '2016-06-05 00:54:16' AND `type` = @jctype; SELECT MAX(createdatetime) INTO @maxdate FROM lotterydata WHERE createdatetime <= '2016-06-05 00:54:16' AND `type` = @jctype; SELECT (UNIX_TIMESTAMP(@datatime) - UNIX_TIMESTAMP(@maxdate) INTO @a; SELECT (UNIX_TIMESTAMP(@mindate) - UNIX_TIMESTAMP(@datatime)) INTO @b; IF (@a < @b) THEN SELECT * FROM lotterydata WHERE createdatetime = @maxdate AND `type` = @jctype ELSE SELECT * FROM lotterydata WHERE createdatetime = @maxdate AND `type` = @jctype END IF END$$DELIMITER ;以上是我的存储过程,但执行行提示语法错误,我实在不知错在哪了,错误我截图上传了,请帮助我。谢谢。
展开
1个回答
展开全部
DECLARE @maxdate DATETIME DEFAULT '1900-01-01 00:00:00';
DECLARE @mindate DATETIME DEFAULT '1900-01-01 00:00:00';
DECLARE @datatime DATETIME DEFAULT '1900-01-01 00:00:00';
DECLARE @jctype VARCHAR DEFAULT '';
这些都删掉
mysql的用户变量(@变量名)不用declare来声明,直接用就可以了,如果一开始要默认值,直接set @变量名=值
DECLARE @mindate DATETIME DEFAULT '1900-01-01 00:00:00';
DECLARE @datatime DATETIME DEFAULT '1900-01-01 00:00:00';
DECLARE @jctype VARCHAR DEFAULT '';
这些都删掉
mysql的用户变量(@变量名)不用declare来声明,直接用就可以了,如果一开始要默认值,直接set @变量名=值
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询