Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7920509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:14:44+00:00 2026-06-03T16:14:44+00:00

Is it possible to do a select directly into a hierarchical user type? Imagine

  • 0

Is it possible to do a select directly into a hierarchical user type?

Imagine a table structure like this:

PARENT
------
ID
NAME

CHILD
-----
ID
PARENT_ID
NAME

Additionally, I have user types like this:

create or replace type child_item as object
(
  ID NUMBER(10),
  NAME VARCHAR(255)
);

create or replace type children_table as table of child_item;

create or replace type parent_item as object
(
  ID NUMBER(10),
  NAME VARCHAR(255),
  CHILDREN CHILDREN_TABLE
);

create or replace type parent_table as table of parent_item;

And a statement like this:

select * from parent p inner join child c on p.id = c.parent_id;

Now, I want the result of that statement to be in an object of type parent_table. Is this somehow possible without the use of a complex FOR loop?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:14:46+00:00Added an answer on June 3, 2026 at 4:14 pm

    You can use COLLECT:

    SELECT parent_item(p.ID, 
                       p.NAME, 
                       CAST(COLLECT(child_item(c.id, c.NAME)) AS children_table))
      FROM PARENT p
     INNER JOIN child c ON p.id = c.parent_id
     GROUP BY p.ID, p.NAME
    

    This will return a list of PARENT_ITEM that you can BULK COLLECT into a PARENT_TABLE.

    You could use COLLECT again in an outer query to get a PARENT_TABLE directly:

    SELECT CAST(COLLECT(parents) AS parent_table)
      FROM (SELECT parent_item(p.ID, 
                               p.NAME, 
                               CAST(COLLECT(child_item(c.id, c.NAME)) 
                                 AS children_table)
                              ) parents
              FROM PARENT p
             INNER JOIN child c ON p.id = c.parent_id
             GROUP BY p.ID, p.NAME)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello is it possible to select custom address after geocoding? Like in image below?
I would like to know if it is possible to select a value with
Is is possible to select specific text string on the page directly without a
I would like to select every column of a table, but want to have
Is is possible to store directly complete XML file into MySQL db and perform
I'm inserting records from one table into another table using a select statement. The
Is it possible, in Microsoft Access 2007, to allow a user to select and
I have a table A. I insert data into table A through a user
It is possible to select a different dataset (query) depending on the value of
Is it possible to select within a select (chaining) with my jQuery? I basically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.