Skip to content

NVL2

  • expr1: The expression that will be tested for a null value. This can be columns, constants, or return values from a function. If expr1 is not null, expr2 is returned; if expr1 is null, expr3 is returned.
  • expr2: The expression that is returned if expr1 is not null. This expression can involve columns, constants, or function return values.
  • expr3: The expression that is returned if expr1 is null. Similar to expr2, this could include columns, constants, or the result of a function.
SELECT NVL2('Hello World', 'Not Null', 'Null') AS Example FROM dual;
Example
-----------
Not Null

The NVL2 function in Oracle evaluates whether the first expression is null or not. If it’s not null, it returns the second expression, and if it’s null, it returns the third expression. In this case, since ‘Hello World’ is not null, ‘Not Null’ is returned.