For those of you interested in the solution: there are two different forms of the
CASEstatement syntax: the so-called simple case and the searched case.
The simple case selects one
WHEN...THENbranch by comparing the value of the expression that appears after the
CASEkeyword with the value of the expressions given in each of the
WHEN...THENbranches. It enters the first branch found where the values are equal to one another:
WHEN expr1 THEN ...statements...
WHEN exprN THEN ...statements...
The searched case syntax simply chooses the first
WHEN...THENbranch for which the condition appearing after the
WHEN cond1 THEN ...statements...
WHEN condN THEN ...statements...
p_find_slashprocedure uses a simple case but accidentally used conditions the
WHEN v_char = '/' THEN ...
What many people don't realize is that syntactically this is perfectly valid. That's because to MySQL, those conditions are simply particular types of expression. It's just that their value will be either
1depending on whether the condition holds
TRUErespectively (consequently, the built-in constants
TRUEare in fact synonyms for
I already emailed a few of you, so if you didn't yet receive an email from me, send me your email address and I'll make sure you get the discount code. I can be reached via email:
Roland dot Bouman at gmail dot com
See you at the UC!