MAX_CARDINALITY

The MAX_CARDINALITY function returns a value representing the maximum number of elements an array can contain. This is the cardinality specified on the CREATE TYPE (Array) statement for the user-defined array type.

MAX_CARDINALITY(array-expression)
array-expression
The expression can be either an SQL variable or parameter of an array data type, or a cast specification of a parameter marker to an array data type.

The result of the function is BIGINT. The result cannot be null.

Example

Assume that array type PHONENUMBERS and array variable RECENT_CALLS are defined as follows:

CREATE TYPE PHONENUMBERS AS INTEGER ARRAY[50];
DECLARE RECENT_CALLS PHONENUMBERS;
The following statement sets LIST_SIZE to the maximum cardinality with which RECENT_CALLS was defined.
SET LIST_SIZE = MAX_CARDINALITY(RECENT_CALLS)

After the statement executes, LIST_SIZE contains 50.