Oracle Call Interface Getting Started
Release 8.1.5 for Windows NT
A68802-01

Library

Product

Contents

Index

PrevNext

2
Building OCI Applications

This chapter provides an overview of how to build Oracle database applications using OCI.
Specific topics discussed are

Writing OCI Applications

The general goal of an Oracle Call Interface application is to connect to an Oracle server, engage in data exchange, and perform necessary data processing. While some flexibility exists in the order in which specific tasks can be performed, every OCI application needs to accomplish particular steps.
The basic programming structure used by an OCI application is as follows:
  1. Initialize the OCI programming environment and processes.
  2. Allocate necessary handles, and establish a server connection and a user session.
  3. Issue SQL statements to the server, and perform necessary application data processing.
  4. Free statements and handles not to be reused, or reexecute prepared statements, or prepare a new statement.
  5. Terminate user session and server connection.

  6.  

     
     
     
     
     

Compiling OCI Applications

When you compile an OCI application, you must include the appropriate OCI header files.

The header files are located in the \ORACLE_HOME\OCI\INCLUDE directory.

Linking OCI Applications

The OCI calls are implemented in dynamic link libraries (DLLs) that Oracle provides. The DLLs are located in the \ORACLE_HOME\BIN directory and are part of the Required Support Files.

To use the Oracle DLLs to make OCI calls, you must link your application with OCI.LIB

You do not have to indicate any special link options.


Note:

Other libraries may be necessary (such as MSVCRT.LIB for Microsoft). These depend on your compiler. 


OCI.LIB

OCI.LIB is a single, programmatic interface to Oracle.


Note:

In the Oracle8 OCI, Oracle has removed any version number from the library name OCI.LIB. 


Client DLL Loading When Using LoadLibrary()

The directories below are searched in the following order by LoadLibrary:

  1. Directory from which the application is loaded
  2. Current directory
  3. On Windows NT:
  4. Directories listed in the PATH environment variable

The Oracle XA Library

The XA Application Program Interface (API) is typically used to enable an Oracle8 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 ORAXA8.DLL must be contained in the execution path of the calling program.


The Oracle XA Library is automatically installed as part of Oracle8 Enterprise Edition. The following components are created in your Oracle home directory:
Component Location

ORAXA8.DLL 

ORACLE_HOME\BIN 

ORAXA.LIB 

ORACLE_HOME\RDBMS\XA 

XA.H 

ORACLE_HOME\RDBMS\XA 

Compiling and Linking an OCI Program with the Oracle XA Library

To compile and link an OCI program:
  1. Compile PROGRAM.C by using Microsoft Visual C++ or Borland C, making sure to include ORACLE_HOME\RDBMS\XA in your path.
  2. Link PROGRAM.OBJ with the following libraries:

  3.  

     
     
     
     
     


    Library Located in...

    ORAXA.LIB 

    ORACLE_HOME\RDBMS\XA 

    OCI.LIB

    ORACLE_HOME\OCI\LIB\MSVC 

     

    or 

     

    ORACLE_HOME\OCI\LIB\BORLAND 

  4. Run PROGRAM.EXE.

XA Dynamic Registration

The Oracle8 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 Oracle8 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:

After adding this variable, see the Oracle8 Server Application Developer's Guide for information on using XA dynamic registration.

Adding an Environmental Variable for the Current Session

Adding an environmental variable at the command prompt affects only the current MS-DOS session.

To add an environmental variable:

Adding a Registry Variable for All Sessions

Adding a registry variable affects all sessions on your Windows NT computer. This is useful for computers where only one TP monitor is running.

To add a registry variable:

  1. Go to the computer where your TP monitor is installed.
  2. On Windows NT, enter the following at the MS-DOS command prompt:

  3.  

     
     
     
     
     

    C:\> REGEDT32

    On Windows 95/98, enter:
    C:\> REGEDIT


    The Registry Editor window appears.
     

  4. Go to HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE.

  5.  

     
     
     
     
     

  6. Choose the Add Value option in the Edit menu.

  7.  

     
     
     
     
     

    The Add Value dialog box appears.
     

  8. Type ORA_XA_REG_DLL in the Value Name text box.
  9. Select REG_EXPAND_SZ from the Data Type list box.
  10. Click OK.

  11.  

     
     
     
     
     

    The String Editor dialog box appears.

  12. Type VENDOR.DLL in the String field, where VENDOR.DLL is the TP monitor DLL provided by your vendor.
  13. Click OK.
    The Registry Editor adds the parameter.
  14. Choose Exit from the Registry menu.

  15.  

     
     
     
     
     

    The registry exits.

Running OCI Applications

To run an OCI application, ensure that the entire corresponding set of RSFs is installed on the machine that is running your OCI application.

Using the Object Type Translator and the INTYPE File

The Object Type Translator (OTT) utility converts database definitions of object types and named collection types into C struct declarations which can be included in an OCI or ProC/C++ application. When running the OTT, the INTYPE file informs the OTT which user-defined types should be translated.
The INTYPE file also controls the naming of the generated structs. The INTYPE file can be a user-created file, or the outtype file of a previous invocation of the OTT. If the INTYPE parameter is not used, all types of the schema to which the OTT connects are translated.


OTT on Windows NT can be invoked from the command line, as on the Solaris platform. OTT parameters can be specified on the command line or in a configuration file. Certain parameters can also be specified in the INTYPE file.


For Windows NT, the default configuration file is
\ORACLE_HOME\PRECOMP\ADMIN\OTT\OTTCFG.CFG.


Additionally, a configuration file may be named on the command line. For complete information, see the OTT online Help.


Additional Information

For more information, see the following documents:
For information on... See...

Writing OCI applications 

Oracle Call Interface Programmer's Guide

Specific information about compiling your application and special compiler options 

Your compiler's documentation 

OTT and INTYPE files 

Oracle Call Interface Programmer's Guide

Online help for OTT 

XA and TP monitors: 

 

Distributed Transaction Processing: The XA Specification published by X/Open, (now part of OpenGroup). Visit: http://www.rdg.opengroup.org/public/pubs/catalog/full_lst.htm 

Transaction Processing XPG4 X/Open CAE Specification XO/CAE/91/300 or C193 2/92

Oracle XA Library

The appendix "Oracle XA" of the Oracle8i Application Developer's Guide


Prev Next
Oracle
Copyright © 1999 Oracle Corporation.
All Rights Reserved.

Library

Product

Contents

Index