1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Oracle SQL CASE Expression

Discussion in 'SQL PL/SQL' started by ygsunilkumar, May 8, 2009.

  1. ygsunilkumar

    ygsunilkumar Active Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    80
    In a simple CASE expression, the Oracle Server searches for the first WHEN ... THEN pair for which pair is equal to comparison expr and returns return_expr.
    If none of the WHEN ... THEN pairs meet this comparison, and an ELSE clause exists, then Oracle returns else_expr
    If the ELSE clause is omitted and no condition is found to be true, then the case statement will return NULL.
    Literal NULL cannot be specified for all the return_exprs and the else_expr

    According to the below example, Literal NULL can be specified for all the return_exprs and the else_expr. Please confirm is that correct or what is Literal NULL means?
    Code (SQL):

    SQL>  SELECT
      2  CASE
      3    WHEN 1 < 2 THEN NULL
      4    WHEN 3 < 4 THEN NULL
      5    ELSE NULL
      6  END
      7  FROM dual;

    C
    -
     
     
  2. salmankhalid

    salmankhalid Forum Advisor

    Messages:
    116
    Likes Received:
    6
    Trophy Points:
    260
    Location:
    Lahore, Pakistan
    First what is Null?
    The value null can be regarded as an unknown value, it doesn't means that it is 0 (zero)

    yeah sure you can use null in return_exprs and else_expr, but it totally depends upon under what conditions you are using the literal Null.......
     
  3. rajavu

    rajavu Forum Guru

    Messages:
    815
    Likes Received:
    52
    Trophy Points:
    610
    Location:
    @ Bangalore , India
    It is not true. You can use it for all expressions.
     
  4. ygsunilkumar

    ygsunilkumar Active Member

    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    80
  5. rajavu

    rajavu Forum Guru

    Messages:
    815
    Likes Received:
    52
    Trophy Points:
    610
    Location:
    @ Bangalore , India
    Hmhm .. Actually I am not sure what does it mean ...