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)