8.12.2 CARDINALITY
Returns the number of array elements in the array data specified for the target data.
- Organization of this subsection
(1) Specification format
scalar-function-CARDINALITY::= CARDINALITY(target-data) target-data::= value-expression
(2) Explanation of specification format
- target-data:
-
Specifies the array data determining the number of array elements
Note the following rules:
-
Specify the target data in the form of a value expression. For details about value expressions, see 7.21 Value expression.
-
Specify array data for the target data. For details about array data, see (7) Array data in 6.2.1 List of data types.
-
You cannot specify a dynamic parameter by itself for the target data.
-
(3) Rules
-
The data type of the execution result is the BIGINT type#.
- #
-
If the integer data type format is a legacy format, it will be an INTEGER type.
-
The NOT NULL constraint does not apply to the value of the execution result (the null value is allowed).
-
If the target data is a null value, the execution result will be a null value.
(4) Examples
- Examples
-
Determine the number of array elements in each row of the array-type column (column C2) of table T1.
SELECT "C1",CARDINALITY("C2") FROM "T1"