Associative Array Type Definition
This is a translation reference to convert the Oracle Associative Array Declaration to Snowflake
This section is a work in progress, information may change in the future.
Some parts in the output code are omitted for clarity reasons.
Description
An associative array (formerly called PL/SQL table or index-by table) is a set of key-value pairs. Each key is a unique index, used to locate the associated value with the syntax
variable_name(index)
.The data type of
index
can be either a string type (VARCHAR2
,VARCHAR
,STRING
, orLONG
) orPLS_INTEGER
. Indexes are stored in sort order, not creation order. For string types, sort order is determined by the initialization parametersNLS_SORT
andNLS_COMP
.
Not to be confused with the PL/SQL NESTED TABLE Type definition.
For the translation, the type definition is replaced by an OBJECT Semi-structured Data Type and then its usages are changed accordingly across any operations.
In order to define an Associative Array type, the syntax is as follows:
To declare a variable of this type:
Sample Source Patterns
Varchar-indexed Associative Array
Oracle
Snowflake
Please note the 'true' parameter in the OBJECT_INSERT. This is so that the element is updated if it is already present in the array.