Associative Array Type Definition

This is a translation reference to convert the Oracle Associative Array Declaration to Snowflake

circle-info

Important Notice: Migration of Documentation Website

Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:

Official Snowflake Snowconvert Documentationarrow-up-right

For any immediate assistance or if you encounter any issues, please contact our support team at [email protected]envelope.

Thank you for your understanding.

circle-exclamation
circle-info

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, or LONG) or PLS_INTEGER. Indexes are stored in sort order, not creation order. For string types, sort order is determined by the initialization parameters NLS_SORT and NLS_COMP.

(Oracle PL/SQL Language Reference ASSOCIATIVE ARRAYSarrow-up-right)

circle-exclamation

For the translation, the type definition is replaced by an OBJECT Semi-structured Data Typearrow-up-right and then its usages are changed accordingly across any operations.

In order to define an Associative Array type, the syntax is as follows:

type_definition := TYPE IS TABLE OF datatype INDEX BY indexing_datatype;

indexing_datatype := { PLS_INTEGER
                     | BINARY_INTEGER
                     | string_datatype
                     }

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.

Numeric-indexed Associative Array

Oracle

Snowflake

Please note that the numeric value is converted to varchar accordingly when the operation needs it. Additionally, note the 'true' parameter in the OBJECT_INSERT. This is so that the element is updated if it is already present in the array.

Record-element Numeric-indexed Associative Array

In this case, the associative array is composed of a Record-structure, and this structure needs to be preserved. For this purpose, further operations on insertions were added.

Oracle

Snowflake

In this scenario, the insertion/update assumes an automatic creation of the record within the associative array and this needs to be taken into account when creating new records.

Known Issues

1. They are currently not being recognized

SnowConvert treats these collections as Nested Table Arrays. There is a work item to fix this.

No related EWIs.

Last updated