Bug #3419 ELSE IF is stored procedures doesn't seem to work
Submitted: 8 Apr 2004 4:35 Modified: 8 Apr 2004 7:35
Reporter: Arnold Daniels Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0 OS:Linux (linux)
Assigned to: Dean Ellis CPU Architecture:Any

[8 Apr 2004 4:35] Arnold Daniels
Description:
ELSE IF is stored procedures doesn't seem to work.

(I use Microsoft Visual Studio with an ODBC connect to more easily write the stored procedures, therefore the weird GO statements)

How to repeat:
This works fine:

DROP PROCEDURE IF EXISTS test
GO

CREATE PROCEDURE test()
BEGIN
	DECLARE id INT(10) unsigned DEFAULT NULL;

	IF id = 1 THEN
		SET id=10;
	ELSE
		SET id=NULL;
	END IF;
END
GO

SHOW CREATE PROCEDURE test
GO 

----------

No rows affected.
Er zijn geen resultaten meer.
(0 row(s) returned)
No rows affected.
Er zijn geen resultaten meer.
(0 row(s) returned)
Procedure                                                        Create Procedure                                                                                                                                                                                                                                                 
---------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
test                                                             CREATE PROCEDURE `test`()
BEGIN
	DECLARE id INT(10) unsigned DEFAULT NULL;

	IF id = 1 THEN
		SET id=10;
	ELSE
		SET id=NULL;
	END IF;
END                                                                                                               
Er zijn geen resultaten meer.
(1 row(s) returned)

------------------------------------------------------------

This doesn't:

DROP PROCEDURE IF EXISTS test
GO

CREATE PROCEDURE test()
BEGIN
	DECLARE id INT(10) unsigned DEFAULT NULL;

	IF id = 1 THEN
		SET id=10;
	ELSE IF id = 2 THEN
		SET id=40;
	ELSE
		SET id=NULL;
	END IF;
END
GO

SHOW CREATE PROCEDURE test
GO 

----------

No rows affected.
Er zijn geen resultaten meer.
(0 row(s) returned)
[MySQL][ODBC 3.51 Driver][mysqld-5.0.0-alpha-standard]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 12
No rows affected.
(0 row(s) returned)
[MySQL][ODBC 3.51 Driver][mysqld-5.0.0-alpha-standard]PROCEDURE test does not exist
No rows affected.
(0 row(s) returned)
[8 Apr 2004 5:22] Arnold Daniels
I misread the documentation. Do I feel stupid now...
Sorry. Please delete this report.

Sorry again.
[8 Apr 2004 7:35] Dean Ellis
Not a bug, as noted.