Bug #34370 "END CASE" syntax is not allowed.
Submitted: 7 Feb 2008 5:08 Modified: 7 Feb 2008 9:33
Reporter: Massimo Heitor Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.51a OS:Windows
Assigned to: CPU Architecture:Any

[7 Feb 2008 5:08] Massimo Heitor
Description:
The documentation (http://dev.mysql.com/doc/refman/5.0/en/case-statement.html) says that CASE statements must be closed by "END CASE", however MySQL gives me syntax errors until I shorten to just "CASE":

(This code is creating an InnoDB table if that is relevant).

How to repeat:
DROP TABLE IF EXISTS Test;
CREATE TABLE Test
(
	A INTEGER NULL,
	B INTEGER NULL
);
INSERT INTO Test (A, B) VALUES (1, 11);
INSERT INTO Test (A, B) VALUES (1, 11);
INSERT INTO Test (A, B) VALUES (2, 12);
INSERT INTO Test (A, B) VALUES (2, 12);
INSERT INTO Test (A, B) VALUES (2, 12);

-- This will NOT work with "END CASE"
SELECT CASE WHEN A = 1 THEN 'It is 1' ELSE 'It is not 1' END CASE FROM Test;
-- This WILL work with just "END"
SELECT CASE WHEN A = 1 THEN 'It is 1' ELSE 'It is not 1' END FROM Test;
[7 Feb 2008 9:33] Sveta Smirnova
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on
how to report a bug at http://bugs.mysql.com/how-to-report.php

You mix CASE operator and CASE statement which is used in Stored Procedures only.

Read about CASE operator at http://dev.mysql.com/doc/refman/5.0/en/control-flow-functions.html#operator_case