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.
Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders. It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.