Converts NULL values.
NVL converts NULL values. When expression 1 is NULL, expression 2 is returned. When expression 1 is not NULL, expression 1 is returned.
Specify the same data types for expression 1 and expression 2. However, if a constant is specified in expression 2, and the data type can also be converted by expression 1, different data types can be specified. When this happens, the conversion by expression 2 is done to suit the data type in expression 1, so the value of expression 2 returned when expression 1 is a NULL value will be the value converted in the data type of expression 1.
Refer to "Table A.1 Data type combinations that contain literals and can be converted implicitly" in "A.3 Implicit Data Type Conversions" for information on data types that can be converted for literals.
Example
In the following example, "IS NULL" is displayed if the value of col1 in table t1 is a NULL value.
SELECT col2, NVL(col1,'IS NULL') "nvl" FROM t1; col2 | nvl ------+--------- aaa | IS NULL (1 row)