Hitachi

Hitachi Advanced Database SQL Reference


8.13.4 NVL

Evaluates the specified target data in the order target-data-1, target-data-2, and then returns the first non-null value.

Note

The scalar functions NVL and ISNULL are functionally equivalent.

Organization of this subsection

(1) Specification format

scalar-function-NVL ::= NVL(target-data-1,target-data-2)
 
  target-data-1 ::= value-expression
  target-data-2 ::= value-expression

(2) Explanation of specification format

target-data-1, target-data-2:

Specifies the target data.

The following rules apply:

(3) Rules

  1. The data type and data length of the execution result will be the data type and data length of target-data-1.

  2. The NOT NULL constraint does not apply to the value of the execution result (the null value is allowed).

  3. If target-data-1 and target-data-2 have null values, the execution result will be a null value.

  4. If target-data-1 has a null value, the value of target-data-2 is converted to the data type and data length of target-data-1.

(4) Example

Example:

Execute the scalar function NVL on the values in column C1 and column C2 in table T1.

SELECT NVL("C1","C2") FROM "T1"

[Figure]