A Relational Table with Object Types (Cont.)


Populating Relational Tables with Object Types
The following example shows how to insert records into the customer table and list the table contents:

01SQL> INSERT INTO  customer  VALUES (101,
02  2    address_typ('715 40th St.,', '#202J', 'Grand Forks', 'ND', '58203') );
03 
041 row created.
05 
06SQL> INSERT INTO  customer  VALUES (102,
07  2    address_typ('University Ave.', 'CS Dept', 'Grand Forks', 'ND', '58202') );
08 
091 row created.
10 
11SQL> SELECT * FROM  customer c  WHERE  c.id = 101;
12 
13 ID          CUST_ADDRESS(ADDRESS1, ADDRESS2, CITY, STATE, ZIP)
14----  --------------------------------------------------------------------
15101   ADDRESS_TYP('715 40th St.,', '#202J', 'Grand Forks', 'ND', '58203')

Resolving Names for Attributes
Name resolution of object type attributes is similar to the resolution of column names in Oracle relational tables.

1SQL> SELECT  c.cust_address.city  FROM  customer c;
2 
3CUST_ADDRESS.CIT
4----------------
5Grand Forks
6Grand Forks

Any attribute names used are associated with the current object instance being pointed to by the SQL statement. Consider the customer table example: