I wanted to create a stored procedure that has a variable in it, so I made this
CREATE PROCEDURE SPTest()
BEGIN
DECLARE @var INT;
END
But it gave me an error
#1064 - 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 '@var INT' at line 3
I've tried all the answer from stackoverflow, I'm using phpmyadmin version 4.5.4.1 and it says up to date. How can I solve this? Thanks in advance
use delimiter :
delimiter
CREATE PROCEDURE SPTest()
BEGIN
DECLARE @var INT;
END
|
delimiter ;
I believe your problem is twofold; the use of @
in the variable name doesn't seem to be supported by MySQL, which is compounded by an apparent phpMyAdmin bug which is causing phpMyAdmin to fail even if the SQL is valid.
I had luck at the command line using this statement:
DELIMITER &
CREATE PROCEDURE SPTest()
BEGIN
DECLARE v INT;
END
&
DELIMITER ;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.