|René Nyffenegger's collection of things on the web|
René Nyffenegger on Oracle - Most wanted - Feedback
Declaration of a PL/SQL collection type
The three collection types are declared as follows:
declare type varchar2_nested_table_type is table of varchar2(100); begin null; end; /
create type number_nested_table_type as table of number /
See deleting and inserting from/to a nested table for an example.
declare type varchar2_varray_type is varray(50) of varchar2(100); begin null; end; /
create type varchar2_varray_type as varray(50) of varchar2(100) /
In the example above, 50 indicates the maximum count of elements in the varray.
declare type varchar2_index_by_type is table of varchar2(100) index by pls_integer; begin null; end; /
Index by tables cannot be declared «globally»; the following construct generates a
create or replace type number_index_by_type is table of number index by pls_integer; /
is versus as
Type declarations within the
declare type varchar2_index_by_type as -- as wrong here, use is instead table of varchar2(100) index by pls_integer; begin null; end; /