Oracle null check for string field

oracle, sql

Solution

Because in Oracle a ZERO length varchar is treated as NULL.

In your example

NVL(NAME, ' ') AS NAME1 will evaluate to either NAME or ' ' - empty string.
NVL(NAME, '') as NAME2 will evaluate to either NAME or a zero length string

Problem

In this below example why other than "NAME1" all giving null as result in oracle 11g. If I mention space explicitly it takes space otherwise null only not empty string.Please help me to clarify this. In NAME2 I specify the empty space but still it gives null. ``` select NVL(NAME,' ') AS NAME1, NVL(NAME,'') AS NAME2, NVL(NAME,NULL) AS NAME3, NAME AS NAME4 from employee ``` OUTPUT : (space),null,null,null

Original source

Related problems