Wednesday, March 3, 2010

Oracle NVL function- TO CHECK THE NULL COLUMN


Oracle NVL function

The NVL function is used to replace NULL values by another value.

The syntax for the NVL function is:
NVL( value_in, replace_with )

value_in if the function to test on null values. The value_in field can have a datatype char, varchar2, date or number datatype.
replace_with is the value that is returned if value_in has a null value. The NVL statement works like this pl/sql code:
if (value_in is NULL) then
  return replace_with;
else
  return value_in;
end if;

Sample code: 

select nvl(salary, 0)
from   employees;

select nvl(ref_code,'Unknown')
from   users;

1 comment:

  1. Oracle NVL Function replace NULL values with a given value in the result of a query. Oracle NVL Function takes two parameters. If expression of first parameter is not null then NVL returns the expression of first parameter, otherwise returns the expression of second parameter.

    See details at: http://www.rahinur.com/oracle-functions/oracle-nvl-function.html

    ReplyDelete