dbTalk Databases Forums  

CASE

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss CASE in the comp.databases.oracle.misc forum.



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

Default CASE - 09-17-2009 , 12:52 PM






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;
/

Reply With Quote
  #2  
Old   
Michel Cadot
 
Posts: n/a

Default Re: CASE - 09-17-2009 , 12:55 PM






"The Magnet" <art (AT) unsu (DOT) com> a écrit dans le message de news: 485f556b-55c7-4cd3-a36a-9e0e6eadd0b9...oglegroups.com...
Quote:
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

Reply With Quote
  #3  
Old   
The Magnet
 
Posts: n/a

Default Re: CASE - 09-17-2009 , 01:06 PM



On Sep 17, 12:55*pm, "Michel Cadot" <micadot{at}altern{dot}org> wrote:
Quote:
"The Magnet" <a... (AT) unsu (DOT) com> a écrit dans le message de news: 485f556b-55c7-4cd3-a36a-9e0e6eadd... (AT) m11g2000vbl (DOT) 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.

Reply With Quote
  #4  
Old   
Michel Cadot
 
Posts: n/a

Default Re: CASE - 09-17-2009 , 01:22 PM



"The Magnet" <art (AT) unsu (DOT) com> a écrit dans le message de news: 7367e101-5f6c-42ff-9bdb-4fb666b44b50...oglegroups.com...
On Sep 17, 12:55 pm, "Michel Cadot" <micadot{at}altern{dot}org> wrote:
Quote:
"The Magnet" <a... (AT) unsu (DOT) com> a écrit dans le message de news: 485f556b-55c7-4cd3-a36a-9e0e6eadd... (AT) m11g2000vbl (DOT) 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

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.