Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   Data Types and Expressions > Expression >

NVL Function

The NVL expression returns different results, depending on whether its first argument evaluates to NULL.

Read syntax diagramSkip visual syntax diagramNVL Function:
 
|--NVL--(--expr1--,--expr2--)-----------------------------------|
 

Element Description Restrictions Syntax
expr1
expr2
Expressions that return values of a compatible data type Cannot be a host variable or a BYTE or TEXT data type Expression, p. Expression

NVL evaluates expression1. If expression1 is not NULL, then NVL returns the value of expression1. If expression1 is NULL, NVL returns the value of expression2. The expressions expression1 and expression2 can be of any data type, as long as they can be cast to a common compatible data type.

Suppose that the addr column of the employees table has NULL values in some rows, and the user wants to be able to print the label Address unknown for these rows. The user enters the following SELECT statement to display the label Address unknown when the addr column has a NULL value:

SELECT fname, NVL (addr, 'Address unknown') AS address 
   FROM employees
Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]