Click or drag to resize

coalesce Function

Verizon Connect Logo
Print this page
Learn more about Verizon Connect GeoBase.
Get information about the latest release
coalesce Function

The coalesce function returns the first (left-most) non-null element from a given set.

Syntax

Alchemy
ret_val = coalesce(value_set);

Nomenclature

ret_val The first (left-most) non-null element in value_set
value_setA set of values to test

Example

The following example demonstrates the use of the coalesce function to select the most-specific known locale for a street (where the street is identified by id) using the lookup function (which returns null if a match is not made):

Alchemy
$my_region = coalesce(lookup(my_suburbs, %id), lookup(my_cities, %id), "Unknown"));

The above line of code is functionally equivalent to the following:

Alchemy
IF lookup(my_suburbs, %id) != NULL
  $my_region = lookup(my_suburbs, %id);

ELSE IF lookup(my_cities, %id) != NULL
  $my_region = lookup(my_cities, %id);

ELSE
  $my_region = "Unknown";