Newsletter Subscription | Glossary | Contact Us
Home > All Categories > MySQL > Education > MySQL Stored Procedures: CASE syntax
Question Title MySQL Stored Procedures: CASE syntax
Authored by: Thomas Darwin
Viewed: 986 times so far
Thank you all for taking the time to respond to the little challenge I posted yesterday! I am pleasantly surprised to note that so many people took the time to post a solution. And most people provided the correct answer too: you are all entitled to a well deserved discount to register for the MySQL User's conference!!!

For those of you interested in the solution: there are two different forms of the CASE statement syntax: the so-called simple case and the searched case



The searched case syntax simply chooses the first WHEN...THEN branch for which the condition appearing after the WHEN keyword is TRUE:



The p_find_slash procedure uses a simple case but accidentally used conditions the WHEN...THEN branches:



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 0 or 1 depending on whether the condition holds FALSE or TRUE respectively (consequently, the built-in constants FALSE and TRUE are in fact synonyms for 0 and 1 respectively).

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!

Author : Roland Bouman
Click Here to View all the questions in Education category.
File Attachments File Attachments
There are no attachment file(s) related to this question.
User Comments User Comments
There are no user comments for this question. Be the first to post a comment. Click Here
Post Comment Add a Comment
Email Address:
Comment/Message
Verify Code

Post Comment How helpful was this article to you?
Related Questions Related Article
  1. MySQL 5.1 data dictionary diagram
  2. MySQL 5.1 partitions in practice
  3. A Primer on Falcon Tablespaces
  4. MySQL Sandbox University lesson - June 12, 14:00 GMT
  5. COUNT(*) vs COUNT(col)
  6. Using XML in MySQL 5.1 and 6.0
  7. High Performance MySQL 2nd Edition is in production
  8. The top 20 design tips for MySQL Enterprise data architects
  9. InnoDB Sessions at MySQL Conference
  10. Database Security Talk
  11. Webinar - Reduce the TCO with MySQL
  12. Reading the guide
  13. How to create a MySQL Database
  14. MySQL Conference Tracks for the DBA
  15. Designing Scalable Architectures with MySQL Proxy
  16. Top 20 DB Design Tips Every Architect Needs to Know part 5
  17. Top 20 DB Design Tips Every Architect Needs to Know
  18. MySQL Special Promotions - Training Services
  19. High Performance MySQL Second Edition Schedule
  20. Top 20 DB Design Tips Every Architect Needs to Know part 3
  21. Interview by Sun TV at MySQL Conference
  22. Top 20 DB Design Tips Every Architect Needs to Know part 4
  23. An Introduction to BLOB Streaming for MySQL part 4
  24. Top 20 DB Design Tips Every Architect Needs to Know part 2
  25. An Introduction to BLOB Streaming for MySQL part 2
  26. An Introduction to BLOB Streaming for MySQL part 3
  27. Two second editions, two first times
  28. An Introduction to BLOB Streaming for MySQL part 5
  29. MySQL Obfuscator, What features do you want to see
  30. An Introduction to BLOB Streaming for MySQL
  31. Drizzling MySQL
  32. Employee MySQL virtual columns
  33. Capacity Planning, Archetecture, Scaling, Response time, Throughput
  34. OSCON 2008 - MySQL Proxy - from architecture to implementation
  35. Wonderful world of MySQL Storage Engines
  36. MySQL Proxy @ OSCON 08
  37. MySQL University Thu 30 Oct
  38. UC2009 - A few days, a few wishes
Article Information Additional Information
Article Number: 134
Created: 2008-03-13 2:36 PM
Rating No Rating
 
Article Options Article Options
Print Question Print this Question/Article
Email Question Email this Question/Article to Friend
Export to MS Word Export to MS Word
Bookmark Article
del.icio.us Bookmark del.icio.us Bookmark
Digg It Digg It
Furl It Furl It
Subscribe to Article Subscribe to Article
 
Language Translation Language Translation
 
Search Knowledge Base Search Knowledge Base