MAX_CARDINALITY scalar function
The MAX_CARDINALITY function returns a value of type BIGINT representing the maximum number of elements that an array can contain. This is the cardinality that was specified in the CREATE TYPE statement for the ordinary array type.
The schema is SYSIBM.
-
array-expression
- An SQL variable, SQL parameter, or global variable of an array type, or a CAST specification of a parameter marker to an array type.
Result
The result can be null; if the argument is an associative array, the result is the null value.
Example
- Return the maximum cardinality of the
RECENT_CALLS
array variable of array typePHONENUMBERS
:
The SQL variableSET LIST_SIZE = MAX_CARDINALITY(RECENT_CALLS)
LIST_SIZE
is set to 50, which is the maximum cardinality that the array typePHONENUMBERS
was defined with.