Votes

Get COUNT of elements in subset of collection (details)
 
Dear Bryn,

I love PL/SQL and especially appreciate associative arrays!

I make extensive use of them, because I can reference both positive and negative index values, and because they can be sparse.

It sure would be nice, though, if I could use the COUNT method and specify the range of values within which I need a count.

Thanks so much!

Currently the COUNT method for collections only returns the total number of elements defined in that collection.

I would like to be able to find out how many elements are defined in the positive or negative index ranges, or say from 1000 to 2000.


Enhance COUNT to take arguments as follows:

my_collection.COUNT (start_index, end_index)

If neither are specified then COUNT works as before.

If only start is specified then return the COUNT from that index to the LAST index.

If only end is specified then return the COUNT from that index to the FIRST index.



DECLARE
   l_collection DBMS_SQL.VARCHAR2A;
BEGIN
   IF l_collection.COUNT (start => 0)

   IF l_collection.COUNT (end => -1)

   IF l_collection.COUNT (1000, 1999)


Steven Feuerstein, PL/SQL Evangelist, Quest Software: "Help me help Oracle improve the PL/SQL language!"


Bryn Llewellyn: "We love to hear from PL/SQL developers. Let us know what is important to you!"

PL/SQL Obsession
Apex Evangelists
O'Reilly Books on Oracle
OTN PL/SQL Best Practices
OTN PL/SQL Page
Steven Feuerstein's Blog