Bug #31358 | Manual and Community-Server differ in DECLARE-syntax | ||
---|---|---|---|
Submitted: | 2 Oct 2007 23:14 | Modified: | 3 Oct 2007 0:11 |
Reporter: | Christoffer Anselm | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S2 (Serious) |
Version: | 5.0.25-community | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | DECLARE, documentation |
[2 Oct 2007 23:14]
Christoffer Anselm
[2 Oct 2007 23:27]
Paul DuBois
Did you remember to change the statement delimiter before defiining the procedure? Remember that you are using compound-statement syntax, so the ';' in the middle of the procedure will be misinterpreted by mysql unless you redefine the delimiter: mysql> CREATE PROCEDURE donations_calculate () MODIFIES SQL DATA -> BEGIN -> DECLARE i_done INT DEFAULT 0; ERROR 1064 (42000): 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 mysql> END -> ; ERROR 1064 (42000): 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 'END' at line 1 mysql> delimiter // mysql> CREATE PROCEDURE donations_calculate () MODIFIES SQL DATA -> BEGIN -> DECLARE i_done INT DEFAULT 0; -> END -> // Query OK, 0 rows affected (0.05 sec)
[3 Oct 2007 0:05]
MySQL Verification Team
Thank you for the bug report. Please see Paul's comment.
[3 Oct 2007 0:11]
Christoffer Anselm
Thanks for that information! Seems that I didn't read the 'CREATE PROCEDURE' manual page as carefully as I should. Stored procedures and declare-statements now work on my machine as they should :)