Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Add support for anonymous array types in SQL and PL/SQL

Lukas EderSep 17 2017 — edited Sep 7 2022

Oracle SQL and PL/SQL strongly favour nominal typing over structural typing, especially when it comes to nested table / varray / associative array / object / record types. In PostgreSQL, in the SQL standard, and in most other languages, an array type is defined as a collection of a base type, without the requirement of assigning a name to such a type, nor to store it somewhere. For example, in Java:

String[] strings = ...

Or in PostgreSQL:

SELECT array_agg(array(first_name, last_name))
FROM customers;

The latter produces a nested text[][] type which can be passed around everywhere such a type is suitable. The same can be done with procedures:

CREATE OR REPLACE FUNCTION my_function (strings IN TEXT[]) RETURN BIGINT[] ...

Of course, entirely different syntaxes, such as e.g. MY_TABLE.MY_COLUMN%TABLE would be possible, too.

It would be really cool if such types were available in Oracle as well. The burden of manually creating and naming a table type every time some type should be transformed to a collection can at times get a bit tedious.

This is related to (and I think it is a prerequisite for) the idea about supporting

Comments
Post Details
Added on Sep 17 2017
4 comments
729 views