Page 155
To access the object-relational features of Oracle8 from OCI programs, C language object representations are required. Fortunately, you can use a new utility called the Oracle Type Translator (OTT) to generate C structure declarations directly from Oracle -named datatypes. Suppose that the following type, defined in the Scott schema, must be accessed from an OCI program:
CREATE TYPE department ( deptno NUMBER(2), dname VARCHAR2(14), loc VARCHAR2(13));
The C structure to represent this type could be generated by using OTT from the command line, as shown in this example:
ott scott/tiger intype=objin.typ outtype=objout.typ code=c hfile=dept.h
The intype, outtype, and hfile parameters specify the input parameter file, the output log file, and the target file, respectively. The code parameter specifies the target language. In its simplest form, the intype file is a text file containing the names of the types to be translated. You also can use intype to specify the case and name of the target structure.
Suppose that the contents of objin.typ follow:
CASE=lower TRANSLATE department AS dept_struct
Here, the outtype file is a log that will contain the resulting C structure, version information, and target header file. The hfile is the target C source file. The simple department type is translated by OTT to the following C structure:
struct dept_struct { OCINumber deptno; OCIString *dname; OCIString *loc; }
OTT also generates a corresponding structure to hold null indicators for the dept_struct, as shown in this code:
struct dept_struct_ind { OCIInd _atomic OCIInd deptno; OCIInd *dname; OCIInd *loc; }
Obviously, it probably would simpler to perform the mapping of this single object by hand. Many objects can be generated from a single input file, however. OTT saves a considerable amount of time and eliminates errors when mapping numerous complex objects.
Page 156
This chapter demonstrated that, although the basic architecture of the server is not new, Oracle8 is much more than a new version of the relational database. The brief overviews of the physical storage improvements, SQL language extensions, management and security enhancements, and core development tool changes gave you the big picture.
In addition to the powerful new object-relational features, numerous other improvements to the core server and server options make the Oracle server more scalable, reliable, extensible, and robust than ever, positioning Oracle8 as the universal data server that will meet the distributed computing needs of the future.