decode
The decode() function is equivalent to the
IF:ELSE IF:ELSE or SWITCH statements. It is interpreted as
IF:THEN:ELSEIF:THEN:ELSE. You can have multiple ELSEIF statements
to achieve the needed evaluations.
Note: In
decode and conditional expressions, null is treated differently.
Theoretically the result from both the following expressions is expected to be the same, but null is
treated differently in each expression. - Select decode(null, null, 1, 2) from dual. It returns 1 because decode assumes null = null.
- Select case when null = null then 1 ELSE 2 end from dual. It returns 2 because this statement assumes null is not equal to null.
decode(test_expr, expr1, return1, expr2, ..., exprN, returnN,
returnX)
| Expression | Result |
|---|---|
|
Use of If
Nok.Traffic.TCH_call_req is NULL, then
Else return
Nok.Traffic.TCH_call_req. |