COUNT is a method that returns the number of elements in a collection. The syntax for using COUNT is as follows:
collection is the name of a collection.
For a varray, COUNT always equals LAST.
The following example shows that an associative array can be sparsely populated (that is, the sequence of assigned elements has "gaps"). COUNT includes only the elements that have been assigned a value.
DECLARE TYPE sparse_arr_typ IS TABLE OF NUMBER INDEX BY BINARY_INTEGER; sparse_arr sparse_arr_typ; BEGIN sparse_arr(-100) := -100; sparse_arr(-10) := -10; sparse_arr(0) := 0; sparse_arr(10) := 10; sparse_arr(100) := 100; DBMS_OUTPUT.PUT_LINE('COUNT: ' || sparse_arr.COUNT); END;
The following output shows that COUNT includes five populated elements: