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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: ** is there PL/SQL for case

RE: ** is there PL/SQL for case

From: Pardee, Roy E <roy.e.pardee_at_lmco.com>
Date: Thu, 07 Aug 2003 15:39:23 -0800
Message-ID: <F001.005C987D.20030807153923@fatcity.com>


9i pl/sql has a case statement--see the docs. Here is sample code copied from said docs:

<quote>
DECLARE
  n number;
BEGIN
  CASE n
    WHEN 1 THEN dbms_output.put_line('n = 1');     WHEN 2 THEN

      dbms_output.put_line('n = 2');
      dbms_output.put_line('That implies n > 1');
    ELSE dbms_output.put_line('n is some other value.');   END CASE;
END;
</quote>

HTH,
-Roy

Roy Pardee
Programmer/Analyst/DBA
SWFPAC Lockheed Martin IT
Extension 8487
-----Original Message-----

Sent: Thursday, August 07, 2003 1:34 PM
To: Multiple recipients of list ORACLE-L

I am not sure in 9i. But in 8i I think you can use "case" in sql but not in pl/sql. You have to use if elsif in pl/sql.

Guang
-----Original Message-----

Joshi
Sent: Thursday, August 07, 2003 4:24 PM
To: Multiple recipients of list ORACLE-L

Hi,
  Is there a statement in pl/SQL like case or is if elsif the only way. Meaning if I need to transalate state depending on input number as follows :

1 - CA
2 - OR
3 - WA
4 - AR

Can I have one statement like case 'state# :

  1. state := 'CA'
  2. state := 'OR'

etc.

or do i have to do :

IF state# = 1 THEN
  state := 'CA';
ELSIF state# = 2 THEN
  state := 'OR';

etc

Thank You.

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
--

Please see the official ORACLE-L FAQ: http://www.orafaq.net
--

Author: Pardee, Roy E
  INET: roy.e.pardee_at_lmco.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services

---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Thu Aug 07 2003 - 18:39:23 CDT

Original text of this message

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