Previous | Table of Contents | Next |
There are several things to keep in mind while designing a data cartridge. Object data types (ODT)
In order for multiple cartridges to operate, make sure that the following schema objects are unique:
A well-defined naming scheme must be used to achieve such uniqueness. I suggest the following naming scheme.
OOOOCCCSSSSSSSSSSSSSSSS
Where
The developer can use Oracle8s extensibility features to declare new datatypes, make use of different programming languages, and leverage new constructs to model and store data in the Oracle8 database. The following constructs are the building blocks for developing data cartridges:
Object Types
Oracle8 allows developers to add new datatypes by making use of object types. Object types are similar to classes in Java or C++. They bundle a data structure and the functions and procedures associated with that structure. An object type must be associated with a column of a table before it can store any data. Each row object in an object type column has a unique identifier known as an Object ID (OID).
Object types consist of attributes and variables that define the data structure they represent, and methods, functions, and procedures that manipulate the underlying data structure. An object type consists of two parts.
The following example shows how to create a simple object type:
create type complex as object ( real_part real, im_part real, member function addcomplex (x complex) return complex ); create type body complex as member function addcomplex (x complex) return complex is begin return complex (real_part + x.real_part, im_part+ x.im_part); end addcomplex; end;
Tip:
Methods can be implemented in PL/SQL, C, or in later releases using Java. For an example of implementing methods in C, please refer to the section on external procedures later in this chapter.
Tip:
The attributes of object types can be other object types, collections, or large objects.
Collections
A collection is an ordered group of elements of the same datatype. The position of an element in the collection is determined by a unique subscript. Collections behave like arrays, except that collections can only have one dimension and must be integer-indexed. Collections can be attributes of an object type. Oracle8 provides two types of collections:
Nested Tables
Nested tables are like one-dimensional arrays, with the following exceptions:
The following example shows how to declare a nested table collection type:
create type projects as table of varchar2(25) create type employee as object ( emp_id integer(4), emp_name varchar2(25), emp_addr varchar2(40), emp_proj projects)
Variable-Size Arrays
VARRAYs have the following features:
The following example shows how to create a VARRAY:
create type projectIDs as varray(20) of number(2) create type department as object ( dept_id number(2), dept_name varchar2(20), dept_projid projectIDs)
Large Object Types
Large objects are used for storing raw, unstructured data such as text, images, audio, or video. LOBs are divided into two parts.
Access to the LOB data is provided through PL/SQL packages and OCI APIs.
Oracle8 supports two types of LOB data: internal and external.
Internal LOBs
Internal LOBs are stored in tablespaces and participate in the transactional model. They can be committed or rolled back just like any other Oracle8 data type. Oracle8 introduces the following three LOB types to replace the Oracle7 datatypes LONG and LONG RAW:
The LOB data types have the following advantages over LONG and LONG RAW:
Previous | Table of Contents | Next |