The function NVL
is and accepts only two expressions as input.
If the first expression is null, the function returns the second expression. Otherwise, the first expression is returned.
Input expressions can also be of different types, if this happens, an implicit cast attempt will be made, if cast is not possible an error will be returned .
In addition, this function always evaluates the two input expressions, making it slightly less performative than COALESCE
.
Illustration of the function NVL
:
.
Documentation Image
COALESCE
is part of the ANSI-92 standard, so 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 must specify at least two expressions, but you can specify more.
Illustration of the function COALESCE
:
Documentation Image