|Oracle Call Interface Getting Started for Windows
Release 9.0.1 for Windows
Part Number A90166-01
This chapter provides an overview of how to build Oracle database applications using OCI.
This chapter contains these topics:
The general goal of an OCI application is to connect to an Oracle Server, engage in some sort of data exchange, and perform necessary data processing. While some flexibility exists in the order in which specific tasks can be performed, every OCI application must accomplish particular steps.
The basic programming structure used by the OCI is as follows:
When you compile an OCI application, you must include the appropriate OCI header files. The header files are located in the
For example, if you are using Microsoft Visual C++ 6.0, you would need to put in the appropriate path in the Directories page of the Options dialog in the Tools menu. See Figure 2-1, "Directories Tab of the Options Dialog".
The OCI calls are implemented in dynamic link libraries (DLLs) that Oracle provides. The DLLs are located in the
\bin directory and are part of the Required Support Files (RSFs).
To use the Oracle DLLs to make OCI calls, you must link your application with
You do not have to indicate any special link options.
oci.lib is a single, programmatic interface to Oracle. Oracle has removed any version number from the library name.
The following directories are searched in this order by
To run an OCI application, ensure that the entire corresponding set of RSFs is installed on the computer that is running your OCI application.
The XA Application Program Interface (API) is typically used to enable an Oracle9i database to interact with a transaction processing (TP) monitor, such as:
You can also use TP monitor statements in your client programs. The use of the XA API is supported from OCI.
The Oracle XA Library is automatically installed as part of Oracle9i Enterprise Edition. The following components are created in your Oracle home directory:
program.cby using Microsoft Visual C++ or Borland C, making sure to include
\rdbms\xain your path.
program.objwith the following libraries:
The Oracle9i database supports the use of XA dynamic registration. XA dynamic registration improves the performance of applications interfacing with XA-compliant TP monitors. For TP Monitors to use XA dynamic registration with an Oracle database on Windows NT, you must add either an environmental variable or a registry variable to the Windows NT computer on which your TP monitor is running. See either of the following sections for instructions:
Adding an environmental variable at the command prompt affects only the current session.
From the computer where your TP monitor is installed, enter the following at the command prompt:
.dll is the TP monitor DLL provided by your vendor.
Adding a registry variable affects all sessions on your Windows NT computer. This is useful for computers where only one TP monitor is running.
On Windows 95/98, enter:
The Registry Editor window appears.
ORA_XA_REG_DLLin the Value Name text box.
REG_EXPAND_SZfrom the Data Type list box.
.dllin the String field, where
.dllis the TP monitor DLL provided by your vendor.
The registry exits.
Refer to the following general information about XA and TP monitors:
The Object Type Translator (OTT) is used to create C-struct representations of Abstract Data Types that have been created and stored in an Oracle9i database.
To take advantage of objects run OTT against the database, and a header file is generated that includes the C structs. For example, if a PERSON type has been created in the database, OTT can generate a C struct with elements corresponding to the attributes of PERSON. In addition, a null indicator struct is created that represents null information for an instance of the C struct.
The INTYPE file tells the OTT which object types should be translated. This file also controls the naming of the generated structs. The INTYPE File Assistant is a wizard that helps developers to create the INTYPE file.
Note that the
CASE specification inside the
INTYPE files, such as
CASE=LOWER, applies only to C identifiers that are not specifically listed, either through a
TRANSLATE statement in the INTYPE file. It is important to provide the type name with the appropriate cases, such as TYPE Person and Type PeRsOn, in the INTYPE file.
The INTYPE File Assistant generates type names in the INTYPE file with the same case as in the database. By default, all of the types in the database are created in upper case.
In order to preserve the case, use double quotes when creating types in the database. For example:
Object type dependencies are not checked by the Oracle INTYPE File Assistant. When adding an object type for inclusion in the INTYPE file, the INTYPE File Assistant does not add other object types with dependency relationships.
The INTYPE File Assistant requires explicit translations for object types or attributes whose names contain non-ASCII characters. These object types or attributes are indicated by the predefined tag Identifier in the fields where the translations would be entered. Users are required to override this tag with the C identifier translation for the corresponding object type or attribute. The INTYPE File Assistant does not create the INTYPE file until all required translations have been entered.
OTT on Windows NT can be invoked from the command line. Additionally, a configuration file may be named on the command line. For Windows NT, the configuration file is
ottcfg.cfg, located in
See the Oracle Call Interface Programmer's Guide for more information about OTT and INTYPE files. In addition, see the online help for OTT.