NULLIF function in Oracle

NULLIF is an advanced function that the Oracle database supports. It is used to compare two expressions. The NULLIF function is supported in the various versions of the Oracle/PLSQL, including, Oracle 12c, Oracle 11g, Oracle 10g and Oracle 9i.

Syntax:

NULLIF( expr1, expr2 )

Parameters:
expr1, expr2: They are used to specify the expressions to compare.

Example 1:

NULLIF (56, 56)

Output:

NULL

Explanation:
Here, the NULLIF function returns NULL since expr1 and expr2 are equal.

Example 2:

NULLIF (‘apple’, ‘pineapple’)

Output:

 ‘apple’

Explanation:
Here, the NULLIF function returns expr1 since expr1 and expr2 are not equal.