MySQL社区

 找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

搜索
查看: 2033|回复: 0
打印 上一主题 下一主题

求助!MySQL在LINUX下存储过程的SQL文不能执行!!

[复制链接]
跳转到指定楼层
1#
发表于 2016-3-25 09:11:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我从PHPstudy的MYSQL5.3导出sql文,在LINUX下5MYSQL5.54版本执行,存储过程不能执行,本人是小白不太懂什么存储过程,请哪位大神指点。
这个是存储过程SQL文
DROP PROCEDURE IF EXISTS `deleteDingdan`;
CREATE PROCEDURE `deleteDingdan`(in deleID int)
BEGIN DELETE FROM wkcx_dingdan WHERE id<deleID AND dayinflag=3; END;


DROP PROCEDURE IF EXISTS `deleteDingdan3`;
CREATE PROCEDURE `deleteDingdan3`()
BEGIN DELETE FROM wkcx_dingdan WHERE printed_time<curdate() AND dayinflag=3; END;


DROP PROCEDURE IF EXISTS `savehistoryDingdan`;
CREATE PROCEDURE `savehistoryDingdan`()
BEGIN declare countlines int default 0;  declare movelines int default 0;  declare moveID int default 0; declare exit handler for sqlexception rollback; START transaction; SELECT COUNT(*) INTO countlines FROM wkcx_dingdan; SELECT historyID INTO moveID FROM dingdan_history WHERE dayinflag=1 ORDER BY historyID ASC limit 1; IF moveID=0 THEN SELECT MAX(historyID) INTO moveID FROM dingdan_history;END IF; IF countlines>0 THEN  INSERT INTO dingdan_history (historyID,add_time,printed_time,dingdanID,dayinflag,dayinjisn,pages,replyURL,clientURL,dingdan) SELECT id,add_time,printed_time,dingdanID,dayinflag,dayinjisn,pages,replyURL,clientURL,dingdan FROM wkcx_dingdan ON DUPLICATE KEY UPDATE dingdan_history.printed_time = wkcx_dingdan.printed_time,dingdan_history.dayinflag = wkcx_dingdan.dayinflag; SET movelines=1; END IF; commit; IF movelines=1 THEN CALL deleteDingdan(moveID); END IF; commit; END;


DROP PROCEDURE IF EXISTS `updateSNPro`;
CREATE PROCEDURE `updateSNPro`(IN snVar VARCHAR(12),IN mCc0int int, IN mCc1int int)
BEGIN DECLARE sncount int default -1; SELECT COUNT(*) INTO sncount FROM printer WHERE dsn=snVar; IF sncount>0 THEN UPDATE printer SET difT


这个是错误信息
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 1
Query OK, 0 rows affected, 1 warning (0.00 sec)

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 1
Query OK, 0 rows affected, 1 warning (0.00 sec)

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'declare movelines int default 0' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'declare moveID int default 0' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'declare exit handler for sqlexception rollback' at line 1
Query OK, 0 rows affected (0.00 sec)

ERROR 1327 (42000): Undeclared variable: countlines
ERROR 1327 (42000): Undeclared variable: moveID
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF moveID=0 THEN SELECT MAX(historyID) INTO moveID FROM dingdan_history' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END IF' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF countlines>0 THEN  INSERT INTO dingdan_history (historyID,add_time,printed_ti' at line 1
ERROR 1193 (HY000): Unknown system variable 'movelines'
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END IF' at line 1
Query OK, 0 rows affected (0.00 sec)

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF movelines=1 THEN CALL deleteDingdan(moveID)' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END IF' at line 1
Query OK, 0 rows affected (0.00 sec)

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 1
Query OK, 0 rows affected, 1 warning (0.00 sec)

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2
ERROR 1327 (42000): Undeclared variable: sncount
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF sncount>0 THEN UPDATE printer SET difTime=UNIX_TIMESTAMP(now())-UNIX_TIMESTAM' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ELSE INSERT INTO printer (id,dsn,online_date,error0,error1) VALUES ('0',snVar,no' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END IF' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 1
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏 分享淘帖 顶 踩
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|申请友链|小黑屋|Archiver|手机版|MySQL社区 ( 京ICP备07012489号   
联系人:周生; 联系电话:13911732319

GMT+8, 2024-5-1 02:11 , Processed in 0.064888 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表