CREATE DEFINER=`root`@`localhost` PROCEDURE `GetStateList`(IN _CountryName VARCHAR(255))
BEGIN
DECLARE @CCode VARCHAR(50)
SET @CCode = (SELECT CountryID from countrylist where CountryName = _CountryName);
SELECT @CCode;
END
Asked
Active
Viewed 13 times
0

Madhur Bhaiya
- 28,155
- 10
- 49
- 57
-
You need to change the `DELIMITER` from semicolon to something else. Check the documentation or a tutorial to see what the syntax should be. – Tim Biegeleisen Oct 24 '18 at 06:44
-
Possible duplicate of [How can I fix MySQL error #1064?](https://stackoverflow.com/questions/23515347/how-can-i-fix-mysql-error-1064) – Nick Oct 24 '18 at 06:49
-
Please see: [Why should I accept an answer when my query is resolved](https://meta.stackexchange.com/a/5235) – Madhur Bhaiya Oct 25 '18 at 04:07
1 Answers
0
You need to redefine the Delimiter to something else (eg: $$
) other than ;
. At the end, reset the limiter back to ;
. Also, a semicolon was missing in the Declare statement:
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `GetStateList`(IN _CountryName VARCHAR(255))
BEGIN
DECLARE @CCode VARCHAR(50); -- semicolon was missing here
SET @CCode = (SELECT CountryID
from countrylist
where CountryName = _CountryName);
SELECT @CCode;
END$$
DELIMITER ;

Madhur Bhaiya
- 28,155
- 10
- 49
- 57