Bug #14042 | Workaround for "empty" ELSE in CASE not documented | ||
---|---|---|---|
Submitted: | 14 Oct 2005 22:24 | Modified: | 13 Jan 2008 11:09 |
Reporter: | Roland Bouman | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S4 (Feature request) |
Version: | 5.0+ | OS: | Any |
Assigned to: | Jon Stephens | CPU Architecture: | Any |
Tags: | case, ELSE, stored procedures |
[14 Oct 2005 22:24]
Roland Bouman
[27 Nov 2005 16:52]
Roland Bouman
Hi, i am using empty BEGIN..END statements now as NOOP statement (thanks Valeriy). Which is fine by me.
[2 Dec 2005 14:34]
Roland Bouman
changed the synopsis
[2 Dec 2005 14:53]
Per-Erik Martin
This would not be standard; a statement is required in the ELSE branch.
[4 Dec 2005 14:02]
Valeriy Kravchuk
No, empty ELSE clause in non-standard. Look: <case statement> ::= <simple case statement> | <searched case statement> <simple case statement> ::= CASE <case operand> <simple case statement when clause>... [ <case statement else clause> ] END CASE ... <case statement else clause> ::= ELSE <SQL statement list> So, please, use BEGIN END trick, if you do not want to put anything useful into ELSE: mysql> create procedure p_Case() begin declare v int default 1; case v when 2 then select v; else begin end; end case; end;// Query OK, 0 rows affected (0,00 sec) mysql> call p_case();// Query OK, 0 rows affected (0,00 sec)
[4 Dec 2005 14:21]
Roland Bouman
ok, fair enough. Thanks again Valeriy
[17 Dec 2007 10:34]
Jon Stephens
This should be mentioned in the documentation, so I've re-opened as a Docs bug and assigned it to myself.
[13 Jan 2008 11:09]
Jon Stephens
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.