Bug #76934 Can't declare variable inside PROCEDURE
Submitted: 4 May 2015 18:02 Modified: 26 Apr 2016 23:34
Reporter: Walter Gabrielsen III Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S1 (Critical)
Version:6.3.3 OS:Windows (Microsoft Windows 8.1)
Assigned to: CPU Architecture:Any
Tags: WBBugReporter

[4 May 2015 18:02] Walter Gabrielsen III
Description:
I can't create a procedure with an internal variable.

How to repeat:
In Workbench, open the query window.

Type in the following code:

CREATE PROCEDURE test ()
BEGIN
 DECLARE a1 VARCHAR(20);
END

On the last parentheses on "varchar(20)" workbench reports a syntax error: missing semi-colon; even though the semicolon is there.

Workbench also reports a syntax error for the "END" statement, which I assume is related to the failure to recognize the existing semicolon.

Upon executing this code it reports a syntax error.
[4 May 2015 18:03] Walter Gabrielsen III
wb.log

Attachment: wb.log (application/octet-stream, text), 20.55 KiB.

[5 May 2015 7:04] Mike Lischke
Verified as described. Thanks for your bug report.

Note: the reported syntax error will not prevent you from creating the stored procedure. The server wills till accept the text (if there are no other problems with it).
[21 Oct 2015 11:35] Alon Perelmutter
Hello, 
I am using Workbench version 6.3.4.0 (build 828) 32 bit and having the same issue on creating SP and without a SP when opening a new query window and type:

DECLARE a1 VARCHAR(20); 
I get the error - DECLARE 'declare' is not a valid input at this position.
Thanks,
[30 Nov 2015 11:32] Mike Lischke
Alon, when you write SP code in a normal query editor then you have to decorate it with the usual DELIMITER statement. Otherwise semicolons within the SP are interpreted as statement end for your entire SP.

Only when you use the Alter Routine editor can you omit the delimiter, because it works specifically for routines and hence doesn't need it.
[26 Apr 2016 23:34] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Workbench 6.3.6 release, and here's the changelog entry:

MySQL Workbench sometimes wrongly detected a syntax error when creating
stored procedures in the SQL editor.

Thank you for the bug report.