Skip to content
Advertisement

DB2 NVL with empty string

As in DB2, empty string and null are unlike in Oracle. Is there any method to realize NVL but with empty string?

Advertisement

Answer

You could combine it with NULLIF:

The NULLIF function returns the null value if the two arguments are equal; otherwise, it returns the value of the first argument.

SELECT NVL(NULLIF(col, ''),'replacement') 
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement