Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Correct syntax for 'CASE WHEN' clause

Re: Correct syntax for 'CASE WHEN' clause

From: Bob <Bob.Xinsley_at_catmktg.com>
Date: 2000/03/21
Message-ID: <38d7807a_3@news.sisna.com>#1/1

Decode. Ah yes, I'd forgotten about that. I work on three different relational data bases, (Oracle, SQL Server, and Red Brick) using two different O/Ses, (Unix and NT) and I sometimes have trouble remembering what works where. For example, Oracle is the only one of the three that doesn't support the 'CASE WHEN' syntax.

Thank you everyone for your prompt and excellent help.

Bob

Change 'X' to 'A' to send me email.

Gennadiy Greenberg wrote in message <38D73D9E.5172F061_at_siemens.com.ua>...
>Bob wrote:
>
>> I'm getting the following error trying to use a 'CASE WHEN' expression in
 a
>> SELECT statement.
>>
>> SQL> select case when contract_coupon_type = 'm'
>> 2 then 'Manufacturer'
>> 3 else 'Retailer'
>> 4 end as x
>> 5 from contract_t;
>> select case when contract_coupon_type = 'm'
>> *
>> ERROR at line 1:
>> ORA-00923: FROM keyword not found where expected
>>
>> I can't find any reference to 'CASE WHEN' in the online Oracle docs.
>> Does Oracle support this? If not, how do I implement equivalent
>> functionality? If so, what am I doing wrong?
>>
>> Both the table name and column name are valid as:
>>
>> Select contract_coupon_type from contract_t;
>>
>> returns valid data.
>>
>> Thanks,
>>
>> Bob
>>
>> Replace 'X' with 'A' to send me mail.
>
>The Oracle doesn't have 'CASE WHEN' clause.
>Try that way:
>
>select DECODE(contract_coupon_type,'m','Manufacturer','Retailer')
>from contract_t;
>
>-----
>Gennadiy Greenberg
>
Received on Tue Mar 21 2000 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US