Oracle 11g: Consider the following two CASE Statements
SEARCHED CASE
with null_table as (select null as null_set from dual )
select
case
when (null_set is null) then 'NULL INDEED'
else 'NOTNULL?'
end as AM_I_NULL_OR_NOT
from null_table
SIMPLE CASE
with null_table as (select null as null_set from dual )
select
case null_set
when (null) then 'NULL INDEED'
else 'NOTNULL?'
end as AM_I_NULL_OR_NOT
from null_table
The Searched CASE evaluates null_set as expected, yet, Simple CASE appears not to do so.
Questions:
How do I perform a Simple CASE evaluation on null_set ?
Why does the Simple CASE evaluate as it does?
In Oracle, null cannot be compared against using the
=operator.For example:
So what you can do is use
NVLto replace null by another value :(make sure your field can never be equal to the value, X in the example.)