dbTalk Databases Forums  

Oracle CASE

comp.databases.oracle.tools comp.databases.oracle.tools


Discuss Oracle CASE in the comp.databases.oracle.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mtek
 
Posts: n/a

Default Oracle CASE - 02-23-2009 , 12:30 PM







Can you have multiple conditions in the WHEN clause of a CASE
statement?


CASE v_subproduct_id
WHEN 197 OR 95 THEN
..
..
..

I get some weird stuff:

LINE/COL ERROR
--------
-----------------------------------------------------------------
45/4 PL/SQL: Statement ignored
46/9 PLS-00382: expression is of wrong type




Reply With Quote
  #2  
Old   
Gints Plivna
 
Posts: n/a

Default Re: Oracle CASE - 02-23-2009 , 03:35 PM






On 23 Febr., 20:30, Mtek <m... (AT) mtekusa (DOT) com> wrote:
Quote:
Can you have multiple conditions in the WHEN clause of a CASE
statement?

* *CASE v_subproduct_id
* *WHEN 197 OR 95 THEN
either

case v
when 197 then 'x'
when 95 then 'x'
end

Or
case when v = 197 or v = 95 then 'x'
end

Gints Plivna
http://www.gplivna.eu


Reply With Quote
  #3  
Old   
Mtek
 
Posts: n/a

Default Re: Oracle CASE - 02-24-2009 , 08:07 AM



On Feb 23, 3:35*pm, Gints Plivna <gints.pli... (AT) gmail (DOT) com> wrote:
Quote:
On 23 Febr., 20:30, Mtek <m... (AT) mtekusa (DOT) com> wrote:> Can you have multipleconditions in the WHEN clause of a CASE
statement?

* *CASE v_subproduct_id
* *WHEN 197 OR 95 THEN

either

case v
when 197 then 'x'
when 95 then 'x'
end

Or
case when v = 197 or v = 95 then 'x'
end

Gints Plivnahttp://www.gplivna.eu
Well, both the 197 & 95 will execute the same code, there is no reason
to code them separately......so, I guess #2 is the way to go. I just
hate having to re-state the variable I am testing over and over again
in each condition......



Reply With Quote
  #4  
Old   
ddf
 
Posts: n/a

Default Re: Oracle CASE - 02-24-2009 , 09:51 AM



On Feb 24, 8:07*am, Mtek <m... (AT) mtekusa (DOT) com> wrote:
Quote:
On Feb 23, 3:35*pm, Gints Plivna <gints.pli... (AT) gmail (DOT) com> wrote:





On 23 Febr., 20:30, Mtek <m... (AT) mtekusa (DOT) com> wrote:> Can you have multiple conditions in the WHEN clause of a CASE
statement?

* *CASE v_subproduct_id
* *WHEN 197 OR 95 THEN

either

case v
when 197 then 'x'
when 95 then 'x'
end

Or
case when v = 197 or v = 95 then 'x'
end

Gints Plivnahttp://www.gplivna.eu

Well, both the 197 & 95 will execute the same code, there is no reason
to code them separately......so, I guess #2 is the way to go. *I just
hate having to re-state the variable I am testing over and over again
in each condition......- Hide quoted text -

- Show quoted text -
Is there nothing in Oracle about which you won't complain?


David Fitzjarrell


Reply With Quote
  #5  
Old   
Michael Austin
 
Posts: n/a

Default Re: Oracle CASE - 02-24-2009 , 07:28 PM



Mtek wrote:
Quote:
On Feb 23, 3:35 pm, Gints Plivna <gints.pli... (AT) gmail (DOT) com> wrote:
On 23 Febr., 20:30, Mtek <m... (AT) mtekusa (DOT) com> wrote:> Can you have multiple conditions in the WHEN clause of a CASE
statement?
CASE v_subproduct_id
WHEN 197 OR 95 THEN
either

case v
when 197 then 'x'
when 95 then 'x'
end

Or
case when v = 197 or v = 95 then 'x'
end

Gints Plivnahttp://www.gplivna.eu

Well, both the 197 & 95 will execute the same code, there is no reason
to code them separately......so, I guess #2 is the way to go. I just
hate having to re-state the variable I am testing over and over again
in each condition......

Then I would (and so should you) tend to question your database design
as to why you have to do this... It may be perfectly valid, all I am
stating is that I would have to reevaluate the design....


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.