10.12.2012 Views

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

Oracle C++ Call Interface Programmer's Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

How to Use the OTT Utility<br />

Overview of the Object Type Translator Utility<br />

The Object Type Translator (OTT) utility assists in the development of applications<br />

that make use of user-defined types in an <strong>Oracle</strong> database server.<br />

Through the use of SQL CREATE TYPE statements, you can create object types. The<br />

definitions of these types are stored in the database and can be used in the creation<br />

of database tables. Once these tables are populated, an <strong>Oracle</strong> <strong>C++</strong> <strong>Call</strong> <strong>Interface</strong><br />

(OCCI), <strong>Oracle</strong> <strong>Call</strong> <strong>Interface</strong> (OCI), or Pro*C/<strong>C++</strong> programmer can access objects<br />

stored in the tables.<br />

An application that accesses object data must be able to represent the data in a host<br />

language format. This is accomplished by representing object types as structures in<br />

C or as classes in <strong>C++</strong>.<br />

You could code structures or classes manually to represent database object types,<br />

but this is time-consuming and error-prone. The OTT utility simplifies this step by<br />

automatically generating the appropriate structure declarations for C or the<br />

appropriate classes for <strong>C++</strong>.<br />

For Pro*C/<strong>C++</strong>, the application only needs to include the header file generated by<br />

the OTT utility. In OCI, the application also needs to call an initialization function<br />

generated by the OTT utility.<br />

For OCCI, the application must include and link the following files:<br />

■ Include the header file containing the generated class declarations<br />

■ Include the header file containing the prototype for the function to register the<br />

mappings<br />

■ Link with the <strong>C++</strong> source file containing the static methods to be called by<br />

OCCI while instantiating the objects<br />

■ Link with the file containing the function to register the mappings with the<br />

environment and call this function<br />

For C, in addition to creating C structures that represent stored datatypes, the OTT<br />

utility also generates parallel indicator structures that indicate whether an object<br />

type or its fields are null. This is not the case for <strong>C++</strong>.<br />

How to Use the OTT Utility<br />

To translate database types to C or <strong>C++</strong> representation, you must explicitly invoke<br />

the OTT utility. In addition, OCI programmers must initialize a data structure called<br />

7-2 <strong>Oracle</strong> <strong>C++</strong> <strong>Call</strong> <strong>Interface</strong> Programmer’s <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!