phpmyadmin wamp mysql无法在程序中声明变量

时间:2016-02-04 09:21:01

标签: mysql stored-procedures wamp

当我尝试按照以下代码创建存储过程时,我有一个不受欢迎的问题 但它显示错误

  

#1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以便在第5行附近使用正确的语法

这是我的代码感谢您的建议。

CREATE DEFINER=root@localhost PROCEDURE item_page_insert(IN cid INT, IN it_title VARCHAR(200), IN tumbnail VARCHAR(300), IN publish_date DATE, IN cover_set VARCHAR(20), IN pcontent TEXT, IN status INT) MODIFIES SQL DATA   
 BEGIN 
DECLARE mpid INT;
SELECT max(pid)+1 INTO mpid
FROM tbpage;
INSERT INTO tbite(cid, pid, it_title, tumbnail, publish_date, cover_set)
VALUES(cid,
       mpid,
       it_title,
       tumbnail,
       publish_date,
       cover_set);
INSERT INTO tbpage(pid, pcontent, set_date, status)
VALUES(mpid,
       pcontent,
       now(),
       status); END;

 DELIMITER ;

1 个答案:

答案 0 :(得分:0)

它应该是     DECLARE mpid AS INT;

尝试一下