4. Understanding the Elements of SQL Statements : SQL Functions : Null Handling Functions : IFNULL, NVL, NVL2 Result Data Types
 
Share this page                  
IFNULL, NVL, NVL2 Result Data Types
If both arguments to an IFNULL, NVL, or NVL2 function are the same data type, the result is that data type. If the two arguments are different data types, they must be comparable data types. For a description of comparable data types, see Assignment Operations (see page Assignment Operations).
When the arguments are different but comparable data types, the following rules are used to determine the data type of the result:
The result type is always the higher of the two data types; the order of precedence of the data types is as follows:
date > money > float4 > float > decimal >bigint> integer > smallint > tinyint
and
c > text > char > varchar > byte > byte varying
The result length is taken from the longest value. For example:
IFNULL (VARCHAR (5), c10)
results in c10.
The result is nullable if either argument is nullable. The first argument is not required to be nullable, though in most applications it is nullable.