ARRAY_MAX_CARDINALITY
Example
Section titled “Example”DECLARE TYPE t_numbers IS TABLE OF NUMBER LIMIT 5;BEGIN DBMS_OUTPUT.PUT_LINE('Maximum number of elements: ' || t_numbers.LIMIT);END;Output
Section titled “Output”Maximum number of elements: 5Explanation
Section titled “Explanation”The ARRAY_MAX_CARDINALITY attribute is used to limit the size of a collection. In the example, a PL/SQL block declares a type t_numbers as a table of numbers, limiting its size to 5 elements. The named block then outputs the limit of the collection, which shows as “5”.
Example
Section titled “Example”CREATE TYPE complex AS ( i INTEGER, r REAL);
SELECT ARRAY_MAX_CARDINALITY(ARRAY[(1,2.3)::complex, (4,5.6)::complex]);Output
Section titled “Output”2Explanation
Section titled “Explanation”The ARRAY_MAX_CARDINALITY function returns the maximum number of elements that any array can contain. The example finds the maximum cardinality for an array of a custom type complex, which consists of two elements - an INTEGER and a REAL number. The output 2 implies that the array contains two elements.