COUNT v12
COUNT
is a method that returns the number of elements in a collection. The syntax for using COUNT
is as follows:
<collection>.COUNT
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 (i.e., there are “gaps” in the sequence of assigned elements). 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 there are five populated elements included in COUNT
.
COUNT: 5