Oracle8 Objects

In Oracle8, an object type combines attributes (data structures) and methods (functions and procedures) into a single programming construct. The object type construct allows programmers to defined their own reusable datatypes for use in PL/SQL programs and table and column definitions.

An instance of an object type is an object in the same way that variables are instances of scalar types. Objects are either persistent (stored in the database) or transient (stored only in PL/SQL variables). Objects can be stored in a database as a row in a table (a row object) or as a column in a table. A table of row objects can be created with syntax such as this:

CREATE TABLE table_name OF object_type;

When stored in the database as a row object, the object (row) has an OID (Object IDentifier) that is unique throughout the database.

Object Types

An object type has two parts: the specification and the body. The specification is required and contains the attributes and method specifications. The syntax for creating the object type specification is:

CREATE [OR REPLACE] TYPE obj_type_name 
[AUTHID CURRENT_USER | DEFINER] -- Oracle8i
AS OBJECT (
   attribute_name datatype,...,
   [MEMBER | STATIC PROCEDURE | FUNCTION   
      program_spec],
   [ORDER | MAP MEMBER FUNCTION 
      comparison_function_spec],
   [PRAGMA RESTRICT_REFERENCES(program_name, 
      purities)]
);

All attribute specifications must appear before all method specifications. Object attributes, like variables, are declared with a name and a datatype. The ...

Get Oracle PL/SQL Language Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.