Just looking at a query and notice it uses NVL(table.column, '')
with nothing between the quotes.
What function would this serve? Isn't that equivalent to a NULL?
Just looking at a query and notice it uses NVL(table.column, '')
with nothing between the quotes.
What function would this serve? Isn't that equivalent to a NULL?
Yes it would be bad programming practice to write that in oracle. It essentially keeps the same value as-is no matter what the column value is. It might even hurt you in performance by not using any indexes that you might have on those columns if this is in the where clause.
In Oracle, yes, that's a pointless expression.
In most databases, however, it would convert NULL
values to the empty string which is different from NULL (here's a separate question on why Oracle treats the empty string as NULL). I would guess that whoever wrote the query was expecting Oracle to follow the ANSI standard and that the code in question has a bug or at least is not functioning the way the author intended.
From oracle documentation:
NVL lets you replace null (returned as a blank) with a string in the results of a query. If expr1 is null, then NVL returns expr2. If expr1 is not null, then NVL returns expr1.
This call is equivalent to simple field reference (table.column).
Such expression could have sense if used in the where part of a query (it can be part of optimization preventing unwanted index usage).