Object Tables   «Prev 

Querying an Object Table using Oracle

Oracle Query Object
SELECT column_name_1,  <column_name_2>
FROM object_table_name alias
WHERE <clause>;

Location 1 The SELECT clause, used for selecting attributes (in this case, columns) from the object table
Location 2 The FROM clause, used for specifying the name of the object table
Location 3 The WHERE clause, used for specifying the criteria for selection from the object table

Object Oriented Programming

Selecting Values from Object Tables

When the ANIMAL table was created, it was based entirely on the ANIMAL_TY datatype:
create table ANIMAL of ANIMAL_TY;

When you select from a table that contains an object type, you refer to the type of the object columns as part of the table’s columns. That is, if you used the ANIMAL_TY datatype as the basis for a column named Animal, then you would select the animal names by selecting Animal.Name from the table. An object table, though, is based on an object type, has no other columns. Therefore, you do not need to reference the object type when accessing the columns. To select the names from the ANIMAL table, just query the attributes directly:
select Name
from ANIMAL;
NAME
-------------------------
FRANCES
BENJI
LYLE

You can refer to the columns within the where clause just as if ANIMAL were a relational table:
select Name
from ANIMAL
where Breed = 'ALLIGATOR';
NAME
-------------------------
LYLE

If the ANIMAL_TY object type used another object type for one of its columns, that object type's column would be referenced during all selects, updates, and deletes.