Is there a performant equivalent to the isnull function for DB2?
Imagine some of our products are internal, so they don't have names:
Select product.id, isnull(product.name, "Internal)
From product
Might return:
1 Socks
2 Shoes
3 Internal
4 Pants
I think
COALESCE
function partially similar to theisnull
, but try it.Why don't you go for null handling functions through application programs, it is better alternative.
COALESCE
function sameISNULL
function Note. you must useCOALESCE
function with same data type of column that you check is null.For what its worth, COALESCE is similiar but
is the exact match you're looking for in DB2.
COALESCE allows multiple arguments, returning the first NON NULL expression, whereas IFNULL only permits the expression and the default.
Thus
Gives you what you're looking for as well as the previous answers, just adding for completeness.
hope this might help someone else out there
I'm not familiar with DB2, but have you tried COALESCE?
ie: