A collection method is a set of functions that return information about a collection or procedures that operate on a collection. A collection method can appear anywhere in PL/SQL except SQL statements. Collection methods can help you use collections and maintain applications in a more efficient manner.
Method | Type | Syntax | Description |
DELETE | Procedure | collection.delete() collection.delete(index) | Deletes elements from a collection. If the number of elements to be deleted is specified, the element at a specified position is deleted. Otherwise, all elements are deleted. |
TRIM | Procedure | collection.trim() collection.trim(number) | Deletes the element at the end of a varray or nested table. If the number of elements to be deleted is specified, the specified number of elements are deleted. Otherwise, the last element is deleted. |
EXTEND | Procedure | collection.extend() collection.extend(number) | Creates a new element at the end of a varray or nested table and sets the element value to NULL. If the number of elements to be created is specified, the specified number of elements are created. |
EXISTS | Function | collection.exist() collection.exist(index) | Checks whether the element at a specific position of the collection exists. |
FIRST | Function | collection.first() | Returns the first index subscript of the collection. Index subscripts are sorted by the collation of the index type. |
LAST | Function | collection.last() | Returns the last index subscript of the collection. Index subscripts are sorted by the collation of the index type. |
COUNT | Function | collection.count() | Returns the number of elements in the collection. |
LIMIT | Function | collection.limit() | Returns the maximum number of elements for a collection type. For nested tables and associative arrays, NULL is returned. |
PRIOR | Function | collection.prior(index) | Returns the previous index value of a specific index subscript. Index values are sorted by the collation of the index type. |
NEXT | Function | collection.next(index) | Returns the next index value of a specific index subscript. Index values are sorted by the collation of the index type. |
In Oracle-compatible syntaxes, the
collection.method( )
subprogram does not contain parameters and can be written ascollection.method
without parentheses.For null collections, only the EXISTS collection method does not throw the predefined exception
COLLECTION_IS_NULL
. If you use other collection methods for null collections, an exception is thrown.