Mysql Error 1064 When Creating Stored Procedure
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about mysql create stored procedure Stack Overflow the company Business Learn more about hiring developers or posting ads with
Error 1064 42000
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up syntax error : 1064 , when creating a stored procedure up vote 1 down vote favorite CREATE table parent_user ( userid int auto_increment PRIMARY KEY, Username varchar(100) NOT NULL, Password varchar(200) NOT NULL, Email varchar(200) NOT NULL ); EDIT : OK so I made some changes: CREATE PROCEDURE `parent_reg` ( pUserName varchar(100) pPassword varchar(200) pEmail varchar(200) ) as Begin Declare Count int Declare ReturnCode int Select Count = Count(Username) from parent_user where Username = @Username If Count > 0 Begin Set ReturnCode = -1 End Else Begin Set ReturnCode = 1 insert into parent_user values (pUserName, pPassword, pEmail) End Select pReturnCode as ReturnValue End But I still got the same error- 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 'pPassword varchar(200) pEmail varchar(200) ) ....' The syntax error is at 'pPassword varchar(200)' mysql database stored-procedures syntax share|improve this question edited Jan 24 at 23:30 asked Jan 24 at 22:54 Sonia Mathews 206 I think it's because of the word "stored", you don't need it. You just need CREATE PROCEDURE –Phiter Fernandes Jan 24 at 22:59 Also there is a select with a comma in the line above the create procedure which idk what is doing there –Phiter Fernandes Jan 24 at 23:00 First, your syntax looks like a strange mixture of SQL Server and MySQL. Second, what is select * from parent_user, doing there? –Gordon Linoff Jan 24 at 23:02 add a comment| 2 Answers 2 active oldest votes up vote 0 down vote accepted This is invalid syntax for MySQL Stored Procedure. The code you posted looks more like Microsoft SQL Server (Transact SQL) syntax. Some observations: MySQL proced
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes http://stackoverflow.com/questions/34982577/syntax-error-1064-when-creating-a-stored-procedure a minute: Sign up Mysql: #1064 error in stored procedure up vote 1 down vote favorite Whenever I try to create the below stored procedure. CREATE PROCEDURE purchaseItem (IN productID INT, IN quantity INT, IN price DECIMAL(10,2) , IN memID INT) BEGIN DECLARE qnty INT DEFAULT 0; SELECT p_Unit INTO qnty FROM product WHERE p_ID = productID; IF qnty >= quantity http://stackoverflow.com/questions/12658955/mysql-1064-error-in-stored-procedure && qnty != 0 THEN INSERT INTO purchase VALUES (NULL, productID, quantity, price, memID, 0, NULL); UPDATE product SET p_Unit = (qnty - quantity) WHERE p_ID = productID; END IF; END; I get the 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 '' at line 3 Can someone please point out me where I'm doing wrong. Thanks! mysql stored-procedures syntax share|improve this question edited Apr 24 '13 at 1:39 Aaron Bertrand 165k18265320 asked Sep 30 '12 at 5:41 don 2372521 What happens if you execute the procedure body line by line - does it work, or do you get the same error? –Anders Lindahl Sep 30 '12 at 5:53 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted Don't forget to change the DELIMITER, try the following query without using SELECT..INTO DELIMITER $$ CREATE PROCEDURE purchaseItem ( IN productID INT, IN quantity INT, IN price DECIMAL(10,2) , IN memID INT ) BEGIN DEC
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss http://stackoverflow.com/questions/31225207/error-1064-in-stored-procedure-in-mysql the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. error 1064 Join them; it only takes a minute: Sign up Error #1064 in stored procedure in mysql up vote -1 down vote favorite if cant to understand my english is because my english is bad.... i will try to explain my problem as best as possible. I try to create a stored procedure in mysql (phpmyadmin) but i have mysql error 1064 this 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 '' at line 3 This is the code of stored procedure: CREATE PROCEDURE `sp_user_insert` (IN `sp_email` varchar(255), IN `sp_password` text, IN `sp_role` int) BEGIN DECLARE `sp_encrypted_password` text; SET `sp_encrypted_password` = SELECT MD5(`sp_encrypted_password`); INSERT INTO `user`( `user_email`, `user_password`, `user_role_id`) VALUES ( `sp_email`, `sp_encrypted_password`, `sp_role`); END And this is the code of the table user: CREATE TABLE IF NOT EXISTS `user` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `user_email` varchar(255) NOT NULL, `user_password` text NOT NULL, `user_role_id` int(11) NOT NULL, PRIMARY KEY (`user_id`) ); PD: I'm sorry, my english is bad :C mysql stored-procedures phpmyadmin share|improve this question asked Jul 4 '15 at 21:22 Nac-Ho 42 add a comment| 2 Answers 2 active oldest votes up vote 0 down vote accepted This will help. Try once. DELIMITER $$; CREATE PROCEDURE sp_user_insert (IN sp_email varchar(255), IN sp_password TEXT, IN sp_role INT(20)) BEGIN DECLARE sp_encrypted_password TEXT; SELECT MD5(sp_password) INTO sp_encrypted_password;