1

I created a nested table, now i want to query this table 1 way i know i.e "select * from pOrder;" so what are the other ways to query a nested table?

CREATE TYPE typ_item AS OBJECT --create object
(prodid NUMBER(5),
price NUMBER(7,2) )

CREATE TYPE typ_item_nst -- define nested table type
AS TABLE OF typ_item;

CREATE TABLE pOrder ( -- create database table
ordid NUMBER(5),
supplier NUMBER(5),
requester NUMBER(4),
ordered DATE,
items typ_item_nst) -- here using the nested type column
NESTED TABLE items STORE AS item_stor_tab


INSERT INTO pOrder             --inserting a single value values
VALUES (800, 80, 8000, sysdate,
typ_item_nst (typ_item (88, 888)));

INSERT INTO pOrder -- i row holding multiple values means " a order id has many product"
VALUES (500, 50, 5000, sysdate, typ_item_nst(
typ_item(55, 555),
typ_item(56, 566),
typ_item(57, 577)));
user272735
  • 10,473
  • 9
  • 65
  • 96
Puneet Kushwah
  • 1,495
  • 2
  • 17
  • 35

1 Answers1

2

Try this

select t.ordid, t.supplier, t.requester, t.ordid, i.prodid, i.price
  from porder t, table(t.items) i

You can read more about Table function in the official documentation.

Michael Lang
  • 3,902
  • 1
  • 23
  • 37
mikron
  • 673
  • 10
  • 19