Your cart
  • IMG
    {{cart_item.name}}
    {{cart_item.variation_attribute_name}}: {{cart_item.variation_attribute_label}}
    {{cart_item.item_unit}}: {{ setCurrency(cart_item.price)}}
    {{ setCurrency(cart_item.price*cart_item.quantity)}}
    Invalid quantity more than stock
Total :
{{setCurrency(cart.sub_total)}}

There is no item in the cart. If you want to buy, Please click here.

Oracle CASE expression

Oracle Database Basic Course

Created by :
Database, Oracle
course
Programming, Software and application
1739
2020-12-07 03:13:23

Oracle CASE expression allows you to add if-else logic to SQL statements without having to call a procedure. The CASE expression evaluates a list of conditions and returns one of the multiple possible results.


Oracle CASE expression has two formats: the simple CASE expression and the searched CASE expression. Both formats support an optional ELSE clause.


simple CASE expression:

The following illustrates the syntax of the simple CASE expression:


CASE e

  WHEN e1 THEN

     r1

  WHEN e2 THEN

     r2

  WHEN en THEN

     rn 

  [ ELSE r_else ]

END


Example: 


Select *from app_list where parent_id = (CASE when :P25_PARENT_ID is NULL THEN 0 

      else :P25_PARENT_ID 

      END)


Searched CASE expression: 

The Oracle searched CASE expression evaluates a list of Boolean expressions to determine the result.


The searched CASE statement has the following syntax:


CASE 

  WHEN e1 THEN r1

  [ WHEN e2 THEN r2]

  ...

  [ELSE

    r_else]

END



Example: 

select name, 

alias, 

(CASE 

WHEN parent_id==0 THEN 'Parent' 

ELSE 'Child' 

END) list_type  

from app_lists;