Skip to content
Advertisement

Is it possible to insert a table type collection within a table collection in PL/SQL

I have a requirement to send back a record type in a table collection which have 2 fields-

  1. Line_id
  2. Fulfillment_set_id

A line_id is always unique but a line_id can have more than one Fulfillment_set_id. So I have created a record type

Is the above collection structure possible or am I missing something because I am not able to get success with it. And how do I insert data into it.

Advertisement

Answer

For a single record, try this:

For a table of line recs:

From Oracle 18c we get pseudo-constructors for record types (called ‘Qualified Expressions’), so you can populate them declaratively:

Output:

If you were to create the types as standalone objects in SQL, that would give you even more flexibility with custom constructors, and the ability to use them in queries.

By the way, the question title refers to collections of collections, but the main issue here seemed to be the PL/SQL record. Hopefully this has answered both, but let me know if it hasn’t.

To achieve the bulk collect mentioned in comments, you will need a collection type defined in SQL, for example:

Then it should work:

Output:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement