Skip Headers

Oracle® Call Interface Programmer's Guide
10g Release 1 (10.1)

Part Number B10779-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Feedback

Go to previous page
Previous
Go to next page
Next
View PDF

D
Getting Started with OCI for Windows

This appendix describes only the features of OCI that apply to the Windows NT, Windows 2000, and Windows XP operating systems.

This chapter contains these topics:

What Is Included in the OCI Package for Windows?

The Oracle Call Interface for Windows package includes:

The OCI for Windows package includes the additional libraries required for linking your OCI programs on Windows NT, and Windows 2000.

See Also:

"OCI Instant Client" for a simplified OCI installation option.

Oracle Directory Structure for Windows

When you install OCI, Oracle Universal Installer creates an ORACLE_BASE\ORACLE_HOME directory on the hard drive of your computer. The default Oracle home directory is C:\oracle\ora10.

The OCI files are located in the ORACLE_BASE\ORACLE_HOME directory, as are the library files needed to link and run OCI applications, and link with other Oracle for Windows NT products, such as Oracle Forms.

The ORACLE_BASE\ORACLE_HOME directory contains the following directories that are relevant to OCI:

Table D-1 ORACLE_HOME Directories and Contents  
Directory Name Contents

\bin

Executable and help files

\oci

Oracle Call Interface directory for Windows files

\oci\include

Header files, such as oci.h and ociap.h

\oci\samples

Sample programs

\precomp\admin\ottcfg.cfg

Object Type Translator utility and default configuration file

Sample OCI Programs for Windows

When OCI is installed, a set of sample programs and their corresponding project files are copied to the ORACLE_BASE\ORACLE_HOME\oci\samples subdirectory. Oracle recommends that you build and run these sample programs to verify that OCI has been successfully installed and to familiarize yourself with the steps involved in developing OCI applications.

To build a sample, run a batch file(make.bat)at the command prompt. For example, to build the cdemo1.c sample, enter the following command:

C:> make cdemo1

After you finish using these sample programs, you can delete them if you choose.

A sample OCI application specific to Windows operating systems is included. cdemomt.c demonstrates OCI multithreading, the thread safety feature of the database. This sample program requires the emp table from the default database. The program spawns two simultaneous threads that attempt to insert different employee names with the same ID numbers. Thread synchronization is demonstrated.

ociucb.c should be compiled using ociucb.bat. This batch file creates a DLL and places it in the ORACLE_BASE\ORACLE_HOME\bin directory. To load user callback functions, set the environment/registry variable ORA_OCI_UCBPKG to OCIUCB.

Compiling OCI Applications for Windows

When you compile an OCI application, you must include the appropriate OCI header files. The header files are located in the \ORACLE_BASE\ORACLE_HOME\oci\include directory.

For example, if you are using Microsoft Visual C++ 6.0, you would need to put in the appropriate path, \oracle\ora10\oci\samples, in the Directories page of the Options dialog in the Tools menu.


Note:

Only Microsoft Visual C++ 6.0 and higher is supported for the current release.


See Also:

Your compiler's documentation for specific information about compiling your application and special compiler options

Linking OCI Applications for Windows

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

To use the Oracle DLLs to make OCI calls, you can either dynamically load the DLL and function entry points, or you can link your application with the import library oci.lib. Oracle only provides the oci.lib import library for use with the Microsoft Compiler. Other compilers, such as Borland, though likely compatible with the Oracle DLLs, are not tested and supported by Oracle for use with OCI.

When using oci.lib with the Microsoft Compiler, you do not have to indicate any special link options.

oci.lib

oci.lib is a single, programmatic interface to Oracle. Oracle has removed any version number from the library name.

Client DLL Loading When Using LoadLibrary()

The following directories are searched in this order by LoadLibrary():

Running OCI Applications for Windows

To run an OCI application, ensure that the entire corresponding set of Required Support Files (RSFs) is installed on the computer that is running your OCI application.

The Oracle XA Library

The XA Application Program Interface (API) is typically used to enable an Oracle 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 Enterprise Edition. Table D-2 lists the components created in your Oracle home directory:

Table D-2 Oracle XA Components  
Component Location

oraxa10.lib

ORACLE_BASE\ORACLE_HOME\rdbms\xa

xa.h

ORACLE_BASE\ORACLE_HOME\rdbms\demo

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++, making sure to include ORACLE_BASE\ORACLE_HOME\rdbms\xa in your path.
  2. Link program.obj with the following libraries shown in Table D-3:
    Table D-3 Link Libraries  
    Library Location

    oraxa10.lib

    ORACLE_BASE\ORACLE_HOME\rdbms\xa

    oci.lib

    ORACLE_BASE\ORACLE_HOME\oci\lib\msvc

    
    
  3. Run program.exe.

Using XA Dynamic Registration

The 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 for the Current Session

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

To add an environmental variable:

From the computer where your TP monitor is installed, enter the following at the command prompt:

C:\> set ORA_XA_REG_DLL = vendor.dll

where vendor.dll is the TP monitor DLL provided by your vendor.

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 or Windows 2000, enter the following at the command prompt:
    C:\> regedt32
    
    

The Registry Editor window appears.