Oracle provides a set of methods that can work with collections for development operations. The development operations can be deleting an element, trimming the collection type, or fetching first and last subscripts. The syntax for all the collection methods is as follows:
[COLLECTION].METHOD (PARAMETERS)
The EXISTS
function checks the existence of an element in a collection. The general syntax of this function is [COLLECTION].EXISTS(<index>)
. It accepts the subscript as the input argument and searches for it in the associated collection. If the element corresponding to the index exists, it returns TRUE,
or else returns FALSE
. It is the only method that doesn't raise any exception when used with a collection.
The following PL/SQL block declares a local nested table collection and its two variables. While one array is uninitialized, the other one is initialized with sample data. It checks the existence of the first element in both arrays:
/*Enable the SERVEROUTPUT...