Nested Tables (Cont.)


Qualifiers are required for object attribute references.

Question: Display all their social security numbers of dependents of employee 101.

SQL> SELECT  ssno  FROM  TABLE( employees.dependents ) 
  2    WHERE  employees.eid = 101; 

SELECT  ssno  FROM  TABLE(employees.dependents)
                          *
ERROR at line 1:
ORA-00904: "EMPLOYEES"."DEPENDENTS": invalid identifier

SQL> SELECT  ssno  FROM 
  2    TABLE( SELECT  e.dependents  FROM  employees e 
  3             WHERE  e.eid = 101 ) d; 

      SSNO
----------
 322456776
 123822332

There are two ways to retrieve from a table of tables:
  1. unnesting via table products and
  2. nested cursors.
Unnesting via Table Products
Q: Retrieve ssno column values from all the dependents of all employees.
SQL> SELECT  e.eid, d.ssno 
  2    FROM  employees e, TABLE( e.dependents )(+) d; 

       EID       SSNO
---------- ----------
       101  322456776
       101  123822332
       102  565534555




      Beauty is only skin deep.