PL/SQL   «Prev 

The REF operator

Typically, a REF value comprises the object's unique identifier (OID) associated with the object table and the row identifier (ROWID) of the row object. The ROWID is used as a means to provide quick access to the object. A REF can be used for implicit joins and easy navigation.
REF may sound a lot like a foreign key. However, there are important differences. REF is more reliable and persistent than a foreign key. This is because REFs do not refer to user-changeable values. Rather, they refer to invisible, internal values such as OID and ROWID.

Oracle implements Objects through the use of TYPEs, defined in a similar way to packages.
Unlike packages in which the instance of the package is limited to the current session, an instance of an object type can be stored in the database for later use. The definition of the type contains a comma separated list of attributes and properties, defined in the same way as
  1. package variables, and
  2. member functions or procedures.
If a type contains member functions or procedures, the procedural work for these elements is defined in the TYPE BODY.
To see how objects can be used, suppose an object is created to represent a person. In this case, a person is defined by three attributes: first_name, last_name and date_of_birth. Returning the age of the person is also desired, so this is included as a member function, get_age.
   first_name     VARCHAR2(30),
   last_name      VARCHAR2(30),
   date_of_birth  DATE,
Type created.