Collection Built-Ins

As we've seen already, there are a number of built-in functions and procedures that apply to collection variables. These functions are collectively known as "collection methods" in honor of their object-like invocation syntax. That is, you invoke them using a "variable-dot-method " style. For functions, use this syntax:

result := collection_variable.function_method (method_argument);

where "result" must be of a datatype that is type-compatible with the method. For procedures, the syntax is:

collection_variable.procedure_method (method_arguments);

The following methods are not available from within SQL; they can only be used within PL/SQL programs. The first seven are functions (and are the same methods available for PL/SQL or index-by tables in PL/SQL Release 2.3), and the last three are procedures. For quick reference purposes, this section documents each method using a standard format, which includes an example.

COUNT

DELETE [ ( i [ , j ] ) ]

WARNING: Confusing behavior results if you TRIM and DELETE the same collection.

EXISTS(i)

EXTEND [ (n [,i] ) ]

FIRST, LAST

LIMIT

PRIOR(i), NEXT(i)

TRIM [ (n ) ]