GeekInterview.com
Series: Subject:
Question: 21 of 196

Query Nested Table Data

How to query nested table column of a table without using table function?
Asked by: sandip01 | Member Since May-2010 | Asked on: May 25th, 2010

View all questions by sandip01   View all answers by sandip01

Showing Answers 1 - 1 of 1 Answers
Pooja

Answered On : Sep 3rd, 2012

There are two general ways to query a table that contains a collection type as a column or attribute. Nest the collections in the result rows that contain them. Distribute or unnest collections so that each collection element appears on a row by itself.

Code
  1. SELECT d.dept_emps
  2.   FROM department_persons d;

DEPT_EMPS(IDNO, NAME, PHONE) ------------------------------------------------------------- PEOPLE_TYP(PERSON_TYP(1, John Smith, 1-650-555-0135), PERSON_TYP(2, Diane Smith, 1-650-555-0135))

Code
  1. SELECT e.*
  2.   FROM department_persons d, TABLE(d.dept_emps) e;

IDNO NAME PHONE ---------- ------------------------------ --------------- 1 John Smith 1-650-555-0135 2 Diane Smith 1-650-555-0135

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.