NVL function in Oracle

NVL is an advanced function that the Oracle database supports. It is used to substitute a value, when a NULL value is encountered. The NVL function is supported in the various versions of the Oracle/PLSQL, including, Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i and Oracle 8i.

Syntax:

NVL (value, replace_with)

Parameters:
value: It is used to specify the value to be tested for a NULL value.
replace_with: It is used to specify the value to return if value is NULL.

Example:

SELECT NVL (attendance, 'Absent')
FROM students;

Explanation:
Here, the NVL function will return ‘Absent’ if the attendance field contains a NULL value. Otherwise, the value of the attendance field will be returned.