Skip to Main Content

SQL & PL/SQL

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!

Nested Table - SELECT

user13117585Aug 22 2019 — edited Aug 23 2019

Hello everybody,

I'm having a look at nested tables and I have a basic question.

I'm reading this page:

https://docs.oracle.com/en/database/oracle/oracle-database/18/adobj/nested-tables-and-varrays-used-in-object-views.html#…

So, imagine I have the following test:

CREATE TYPE my_type AS OBJECT

(

  key VARCHAR2(100),

  value VARCHAR2(100)

);

/

CREATE TYPE my_map AS TABLE OF my_type;

/

CREATE TABLE my_table

(

  id NUMBER,

  name VARCHAR2(1000),

  map my_map

)

NESTED TABLE map STORE AS map_nt;

INSERT INTO my_table VALUES

         (

            1,

            'name 1',

            my_map( my_type('foo', 'fooValue'),

                    my_type('bar', 'barValue')

                  )

          );

INSERT INTO my_table VALUES

         (

            2,

            'name 2',

            my_map( my_type('zoo', 'zooValue'),

                    my_type('yum', 'yumValue')

                  )

          );

I was wondering if I could SELECT the content and have this output:

ID     NAME          MAP

1      name 1        [[foo - fooValue][bar - barValue]]

2      name 2        [[zoo - zooValue][yum - yumValue]]

Any advice is welcome,

Regards,

This post has been answered by mathguy on Aug 22 2019
Jump to Answer
Comments
Post Details
Added on Aug 22 2019
9 comments
2,587 views