-- force output for NOT NULL values
NVL(your_variable, Value_if_null)
-- OR (force outputs for both NOT NULL and NULL values)
NVL2(your_variable, value_if_not_null, value_if_null)
SELECT NVL(NULL, 'N/A') FROM dual;
NVL2( string_to_test, value_if_NOT_null, value_if_null )
/*
NVL checks if first argument is null and returns second argument.
NVL2 has different logic. If first argument is not null
then NVL2 returns second argument, but in other case it will
return third argument.
*/
select nvl(null, 'arg2') from dual
-- Result: arg2;
select nvl2('arg1', 'arg2', 'arg3') from dual
-- Result: arg2
select nvl2(null, 'arg2', 'arg3') from dual
-- Result: arg3