My code:
select COALESCE (null, '')
from dual
in Oracle returns null
result, but
select COALESCE (null, '')
in SQL Server returns a ''
result.
Why did this result differ?
They are ANSI standards, shouldn't it be the same?
In the Oracle document about NULL
Oracle Database treats a character value with a length of zero as null.
Oracle internally changes the empty string to a NULL
value. Oracle simply won't insert an empty string.
select null from dual
is the same as
select '' from dual
They all return NULL
.
So when you use select COALESCE (null, '') from dual
it will translate to select COALESCE (null, null) from dual
in Oracle.
Here is a link which talk about this.