The Oracle Pro*C/C++ precompiler allows programmers to use user-defined data types in C and C++ programs.
4.5.1 About Pro*C/C++
Pro*C developers can use the Object Type Translator to map Oracle object types and collections into C data types to be used in the Pro*C application.
Pro*C provides compile time type checking of object types and collections and automatic type conversion from database types to C data types.
Pro*C includes an EXEC SQL syntax to create and destroy objects and offers two ways to access objects in the server:
An interface to the object cache (described under "Oracle Call Interface (OCI)"), where objects can be accessed by traversing pointers, then modified and updated on the server.
For a complete description of the Pro*C/C++ precompiler, see Pro*C/C++ Programmer's Guide
4.5.2 Associative Access in Pro*C/C++
Pro*C/C++ offers the following capabilities for associative access to objects:
Support for transient copies of objects allocated in the object cache
Support for transient copies of objects referenced as input host variables in embedded SQL
DELETEstatements, or in the
WHEREclause of a
Support for transient copies of objects referenced as output host variables in embedded SQL
Support for ANSI dynamic SQL statements that reference object types through the
DESCRIBEstatement, to get the object's type and schema information
For background information on associative access, see "Associative Access in OCI Programs".
4.5.3 Navigational Access in Pro*C/C++
Pro*C/C++ offers the following capabilities to support a more object-oriented interface to objects:
Support for dereferencing, pinning, and optionally locking an object in the object cache using an embedded SQL
Allowing a Pro*C/C++ user to inform the object cache when an object has been updated or deleted, or when it is no longer needed, using embedded SQL
Support for creating new referenceable objects in the object cache using an embedded SQL
Support for flushing changes made in the object cache to the server with an embedded SQL
For background information on navigational access, see "Navigational Access in OCI Programs".
4.5.4 Conversion Between Oracle Types and C Types
Pro*C/C++ provides ease-of-use enhancements to simplify use of OCI types in C and C++ applications.
The C representation for objects that is generated by the Oracle Type Translator (OTT) uses OCI types which are opaque and insulate you from changes to their internal formats, but are cumbersome to use in a C or C++ application. These representations include
OCINumber for scalar attributes and
OCIRef types for collection types and object references.
With Pro*C/C++ enhancements:
Object attributes can be retrieved and implicitly converted to C types with the embedded SQL
Object attributes can be set and converted from C types with the embedded SQL
Collections can be mapped to a host array with the embedded SQL
GETstatement. Furthermore, if the collection is comprised of scalar types, then the OCI types can be implicitly converted to a compatible C type.
Host arrays can be used to update the elements of a collection with the embedded SQL
SETstatement. As with the
GETstatement, if the collection is comprised of scalar types, C types are implicitly converted to OCI types.
4.5.5 Oracle Type Translator (OTT)
The Oracle Type Translator (OTT) is a program that automatically generates C language structure declarations corresponding to object types.
OTT makes it easier to use the Pro*C precompiler and the OCI server access package.