Starting with Oracle9i, PL/SQL                                                        
                            
 supports the use of case statements                                                   
                            
 and                                                                                   
                            
 case expressions. These constructs                                                    
                            
 are often convenient to use in place                                                  
                            
 of complex if-then-else logic and                                                     
                            
 function similarly to counterparts in                                                 
                            
                                                                                       
                            
 other languages (e.g. the C switch                                                    
                            
 statement).                                                                           
                            
                                                                                       
                            
 Case statements are standalone                                                        
                            
 statements that can appear anywhere                                                   
                            
 any                                                                                   
                            
 other PL/SQL statement can appear.                                                    
                            
 Case expressions are similar to case                                                  
                            
 statements, but return a value and                                                    
                            
 can only appear in places where any                                                   
                            
 other PL/SQL expression can appear.                                                   
                            
                                                                                       
                            









Rick


                                                                                       
                                            
                      "Guang Mei"                                                      
                                            
                      <[EMAIL PROTECTED]>        To:       Multiple recipients of list 
ORACLE-L <[EMAIL PROTECTED]>               
                      Sent by:                 cc:                                     
                                            
                      [EMAIL PROTECTED]        Subject:  RE: ** is there PL/SQL for 
case                                           
                      .com                                                             
                                            
                                                                                       
                                            
                                                                                       
                                            
                      08/07/2003 04:34                                                 
                                            
                      PM                                                               
                                            
                      Please respond to                                                
                                            
                      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-----
      From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf
      Of A Joshi
      Sent: Thursday, August 07, 2003 4:24 PM
      To: Multiple recipients of list ORACLE-L
      Subject: ** is there PL/SQL for case

      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: 
  INET: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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).

Reply via email to