Oracle NVL2 Function:
NVL2() function is an extend version of the NVL() function with different options based on whether a NULL value exists.
Oracle NVL2() function allow three parameters. If the first parameter is not null, then it returns the second parameter. In case the second parameter is null, then it returns the third parameter.
- Syntax of the NVL2() function:
NVL2(elm1, elm2,elm3)
Example 1: Here in this example we are checking the first argument, if the first argument is not null, it will return second argument.
select nvl2(1,'vikas','pandey') from dual;
Example 2: Here in this example we are checking the first argument, if the first argument is null, it will return third argument.
select nvl2(null,'vikas','pandey') from dual;