About collection types v16
The most commonly known type of collection is an array. In EDB Postgres Advanced Server, the supported collection types are:
To set up a collection:
- Define a collection of the desired type. You can do this in the declaration section of an SPL program, which results in a local type that you can access only in that program. For nested table and varray types, you can also do this using the
CREATE TYPEcommand, which creates a persistent, standalone type that any SPL program in the database can reference.
- Declare variables of the collection type. The collection associated with the declared variable is uninitialized at this point if no value assignment is made as part of the variable declaration.
- Uninitialized collections of nested tables and varrays are null. A null collection doesn't yet exist. Generally, a
COLLECTION_IS_NULLexception is thrown if a collection method is invoked on a null collection.
- To initialize a null collection, you must either make it an empty collection or assign a non-null value to it. Generally, a null collection is initialized by using its constructor.
- Uninitialized collections of associative arrays exist but have no elements. An existing collection with no elements is called an empty collection.
- To add elements to an empty associative array, you can assign values to its keys. For nested tables and varrays, generally its constructor is used to assign initial values to the nested table or varray. For nested tables and varrays, you then use the
EXTENDmethod to grow the collection beyond its initial size set by the constructor.
Multilevel collections (that is, where the data item of a collection is another collection) aren't supported.
Columns of collection types aren't supported.
For example, you can create an array
varchar2_t, but you can't create a table using array
varchar2_tas a column data type.