The function NVL
is specific to Oracle and only accepts two expressions as input.
If the first expression is null, the function will return the second expression. Otherwise, the first expression will be returned.
Input expressions can also be of different types, if this happens, an attempt will be made to cast implicit, if the cast is not possible an error will be returned.
Also, this function always evaluates the two input expressions, making it slightly less performative than the COALESCE
.
Illustration of function NVL
:
.
Documentation image
The COALESCE
is part of the pattern ANSI-92, therefore it is a command that exists in all databases that follow this pattern or higher.
It always returns the first non-null value in the expression list. You need to specify at least two expressions, but you can specify more.
Illustration of function COALESCE
:
Documentation image
Related (about MS-SQL/T-SQL): https://answall.com/q/55733
– bfavaretto