CASE expression in SQL statements
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: CASE expression in SQL statements

  1. #1
    Join Date
    Feb 2001
    Posts
    100

    Question

    Hi all,

    How to use the CASE in the SQL statements. I tried the following example but it does not work.

    SQL> ED
    Wrote file afiedt.buf

    1 DECLARE X
    2 X:=1;
    3 BEGIN
    4 select AVG(CASE WHEN t.f2 > 6000 then t.f2 ELSE 6000 END) from temp t;
    5 END;
    6* .
    SQL> /
    select AVG(CASE WHEN t.f2 > 6000 then t.f2 ELSE 6000 END) from temp t;
    *
    ERROR at line 4:
    ORA-06550: line 4, column 12:
    PLS-00103: Encountered the symbol "CASE" when expecting one of the following:
    ( - + all mod null
    avg
    count current distinct max min prior sql stddev sum unique
    variance execute cast trim forall



    Can use the CASE in the UPDATE statement as well and how?



    Please advice.

    Thanks

  2. #2
    Join Date
    May 2001
    Location
    San Francisco, California
    Posts
    510
    You might be using an incorrect oracle version.

    [Edited by kris109 on 03-08-2002 at 04:30 PM]
    Remember the Golden Rule - He who has the gold makes the rules!
    ===================
    Kris109
    Ph.D., OCP 8i, 9i, 10g, 11g DBA

  3. #3
    Join Date
    Feb 2001
    Posts
    100
    You're right.

    I did the test on the Oracle 8.1.5. , then I used Oracle 8.1.7 and it works.


    Thank u very much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width