CREATE PROCEDURE dorepeat(IN p1 INT) BEGIN DECLARE x INT DEFAULT 0; REPEAT SET x = x + 1; UNTIL x > p1 END REPEAT; END
I get an syntax 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
But for me, everything seems to be correct. i really don't have any clue! can anybody help?
thanks
According to the MySQL manual, DECLARE is only allowed inside a BEGIN ... END block, and must be at the start. You're also forgetting a semicolon on the end of each line.
The MySQL 1064 error is a syntax error. This means the reason there's a problem is because MySQL doesn't understand what you're asking it to do. However, there are many different situations that can lead to this type of miscommunication between you and your database.
The declaration of a variable generally takes the following syntax: dataType variableName ; dataType variableName ; Where dataType is a type-specifier which is any Java data type and variableName is the unique name of a variable.
You need to temporarily change the delimiter so the MySQL client doesn't think you're done with your statement when it sees the semicolon on line 3:
DELIMITER // CREATE PROCEDURE dorepeat(IN p1 INT) BEGIN DECLARE x INT DEFAULT 0; REPEAT SET x = x + 1; UNTIL x > p1 END REPEAT; END// DELIMITER ;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With