At 12:40 -0800 3/9/05, Homam S.A. wrote:
Thanks Tom, Daniel, and Philippe for you replies.

Yes, I got the statement working exactly as I wrote
it. I was confused about this documentation:

http://dev.mysql.com/doc/mysql/en/case-statement.html

which states that you need to specify "END CASE"
instead of just "END". So I used the same syntax as
T-SQL with "END" and it worked fine.

It sounds as though you read the first paragraph, but not the second, which states:

Note: The syntax of a CASE statement shown here for use inside a stored
procedure differs slightly from that of the SQL CASE expression described in
Section 12.2, "Control Flow Functions". The CASE statement cannot have an
ELSE NULL clause, and it is terminated with END CASE instead of END.


You're using a CASE expression, not a CASE statement.



Homam



--- Tom Crimmins <[EMAIL PROTECTED]> wrote:

On Wednesday, March 09, 2005 07:49, Philippe Poelvoorde wrote:

 > Daniel Kasak wrote:
 >> Homam S.A. wrote:
 >>
 >>> In the documentation, it doesn't mention which
 version
 >>> of MySQL supports the CASE statement, but it
 refers to
 >>> stored procedures, so is it only supported for
 5.x?
 >>>
 >>> I can't get any example of a CASE statement work
 in MySQL.
 >>>
 >>>
 >>>
 >> <snipped>
 >>
 >>> For example, I can execute the following in MS
 SQL
 >>> Server:
 >>>
 >>> UPDATE MyTable
 >>> SET
 >>> field1 = CASE WHEN field3 = 1 THEN 10 ELSE 20
 END,
 >>> field2 = field2 | CASE WHEN field4 = 'B' THEN 1
 ELSE 0
 >>> END | CASE WHEN field4 = 'C' THEN 2 ELSE 0 END

 What error do you get? I can get a statement similar
 to this to work.

 >> Case works in 4.0.x ( and maybe before, haven't
 checked ).
 >> Your problem is elsewhere.
 >> I'm not sure if you can use the pipe symbol as an
 OR operator in the
 >> way you want - to be honest I haven't used it at
 all in SQL.
 >> Try rewriting it to use nothing but case
 statements ( no | operators
 >> ).
 >>
 >
 >

http://dev.mysql.com/doc/mysql/en/logical-operators.html
 >
 > it's || not | (not sure about bit-operation...)

 The | is a bitwise OR.

 http://dev.mysql.com/doc/mysql/en/bit-functions.html

 --
 Tom Crimmins
 Interface Specialist
 Pottawattamie County, Iowa

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:


http://lists.mysql.com/[EMAIL PROTECTED]



-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]


--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to