Re: CASE

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Thu, 17 Sep 2009 20:22:07 +0200
Message-ID: <4ab27e53$0$22590$426a74cc_at_news.free.fr>


"The Magnet" <art_at_unsu.com> a écrit dans le message de news: 7367e101-5f6c-42ff-9bdb-4fb666b44b50_at_o36g2000vbl.googlegroups.com... On Sep 17, 12:55 pm, "Michel Cadot" <micadot{at}altern{dot}org> wrote:
> "The Magnet" <a..._at_unsu.com> a écrit dans le message de news: 485f556b-55c7-4cd3-a36a-9e0e6eadd..._at_m11g2000vbl.googlegroups.com...
> |
> | This is actually proving harder to find than I originally thought. In
> | PLSDQL, can't I have some CASE statement like this. I want to use an
> | OR in the WHEN clause......
> |
> |
> | DECLARE
> | x number := 1;
> |
> | BEGIN
> | CASE x
> | WHEN 1 OR 2 OR 3 THEN
> | DBMS_OUTPUT.PUT_LINE('YES');
> | ELSE
> | DBMS_OUTPUT.PUT_LINE('NO');
> | END CASE;
> | END;
> | /
>
> SQL> DECLARE
> 2 x number := 1;
> 3
> 4 BEGIN
> 5 CASE
> 6 when x=1 or x=2 or x=3 THEN
> 7 DBMS_OUTPUT.PUT_LINE('YES');
> 8 ELSE
> 9 DBMS_OUTPUT.PUT_LINE('NO');
> 10 END CASE;
> 11 END;
> 12 /
> YES
>
> PL/SQL procedure successfully completed.
>
> Regards
> Michel

Yeah, I was hoping to make it like an IN clause.....but guess this is the way.


SQL> DECLARE
  2 x number := 1;
  3
  4 BEGIN
  5 CASE

  6     when x in (1,2,3) THEN
  7        DBMS_OUTPUT.PUT_LINE('YES');
  8      ELSE
  9        DBMS_OUTPUT.PUT_LINE('NO');

 10 END CASE;
 11 END;
 12 /
YES PL/SQL procedure successfully completed.

Regards
Michel Received on Thu Sep 17 2009 - 13:22:07 CDT

Original text of this message