meta data for this page
  •  

*nvl

Library: fbudf

Added in: 1.0 (Win), 1.5 (Linux)

Better alternative: Internal function COALESCE()

Description

The four nvl functions – for integers, bigints, doubles and strings, respectively – are NULL replacers. They each return the first argument's value if it is not NULL. If the first argument is NULL, the value of the second argument is returned.

Result type: varies, see declarations.

Syntax

invl (int1, int2)
i64nvl (bigint1, bigint2)
dnvl (double1, double2)
snvl (string1, string2)

As from Firebird 1.5, use of the internal function COALESCE is preferred.

Warning: i64nvl and dnvl will return wrong and/or bizarre results if it is not absolutely clear to the engine that each argument is of the intended type (NUMERIC(18,0) or DOUBLE PRECISION). If in doubt, cast both arguments explicitly to the declared type (see declarations below).

Declarations

DECLARE EXTERNAL FUNCTION invl
  INT BY DESCRIPTOR, INT BY DESCRIPTOR
  RETURNS INT BY DESCRIPTOR
  ENTRY_POINT 'idNvl' MODULE_NAME 'fbudf'

DECLARE EXTERNAL FUNCTION i64nvl
  NUMERIC(18,0) BY DESCRIPTOR, NUMERIC(18,0) BY DESCRIPTOR
  RETURNS NUMERIC(18,0) BY DESCRIPTOR
  ENTRY_POINT 'idNvl' MODULE_NAME 'fbudf'

DECLARE EXTERNAL FUNCTION dnvl
  DOUBLE PRECISION BY DESCRIPTOR, DOUBLE PRECISION BY DESCRIPTOR
  RETURNS DOUBLE PRECISION BY DESCRIPTOR
  ENTRY_POINT 'idNvl' MODULE_NAME 'fbudf'
 
DECLARE EXTERNAL FUNCTION snvl
  VARCHAR(100) BY DESCRIPTOR, VARCHAR(100) BY DESCRIPTOR,
  VARCHAR(100) BY DESCRIPTOR RETURNS PARAMETER 3
  ENTRY_POINT 'sNvl' MODULE_NAME 'fbudf'