VARRAY (Cont.)


We can not access any numbered subscript extension, except by mapping a VARRAY into a programming language array.
  1. Question: Find the number of extensions that the person with social security number 123897766 has in the phonebook table.    

    The COUNT function returns the number of rows in the query.

  2. Question: List the people in the phonebook table who have extension 123.    
SQL> CREATE TYPE  ssno_set  AS TABLE OF INT; 

Type created.

SQL> SELECT  e.eid, CAST ( MULTISET ( 
  2      SELECT  d.ssno FROM  TABLE( e.dependents ) d 
  3        WHERE  d.age < 16 ) AS ssno_set ) AS dep_ssno 
  4    FROM  employees e; 

       EID                  DEP_SSNO
-----------------------     -------------------------------
       101                  SSNO_SET(32245776, 123822332)
       102                  SSNO_SET(565534555)