Oracle® Call Interface Programmer's Guide, 10g Release 2 (10.2) Part Number B14250-01 |
|
|
View PDF |
This appendix describes only the features of OCI that apply to the Windows 2003, Windows 2000, and Windows XP operating systems.
This chapter contains these topics:
The Oracle Call Interface for Windows package includes:
Oracle Call Interface (OCI)
Oracle Universal Installer
Header files for compiling OCI applications
Library files for linking OCI applications
Sample programs for demonstrating how to build OCI applications
The OCI for Windows package includes the additional libraries required for linking your OCI programs.
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 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
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 in the directory samples
:
C:> make cdemo1
After you finish using these sample programs, you can delete them if you choose.
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
.
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 Microsoft Visual C++, \ORACLE_BASE\ORACLE_HOME\oci\lib\msvc
needs to be specified in the libraries section of the Option dialog box. For Borland compiler, \ORACLE_BASE\ORACLE_HOME\oci\lib\bc.
For example, if you are using Microsoft Visual C++ 6.0, you would need to put in the appropriate path, \oracle\ora10\oci\include
, in the Directories page of the Options dialog in the Tools menu.
Note: The only Microsoft Visual C++ releases supported for the current OCI release are 6.0 and higher. |
See Also: Your compiler's documentation for specific information about compiling your application and special compiler options |
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).
Oracle only provides the oci.lib
import library for use with the Microsoft Compiler. Borland compiler is also supported by Oracle for use with OCI. Oracle recommends that applications must always link with oci.lib
to avoid relinking or compilation with every release.
When using oci.lib
with the Microsoft Compiler, you do not have to indicate any special link options.
Oracle Corporation recommends that applications be linked with oci.lib
, which takes care of loading the correct versions of the Oracle DLLs.
The following directories are searched in this order by LoadLibrary()
:
Directory from which the application is loaded or the directory where oci.dll
is located
Current directory
Windows:
32-bit Windows system directory (system32)
. Use the GetWindowsDirectory()
function to obtain the path of this directory.
16-bit Windows directory (system)
. There is no Win32 function that obtains the path of this directory, but it is searched.
Directories that are listed in the PATH environment variable
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 XA Application Program Interface (API) is typically used to enable an Oracle database to interact with a transaction processing (TP) monitor, such as:
BEA Tuxedo
IBM Transarc Encina
IBM CICS
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. oci.lib
now contains the XA exports:
To compile and link an OCI program:
Compile program
.c
by using Microsoft Visual C++ or the Borland compiler, making sure to include ORACLE_BASE\ORACLE_HOME
\rdbms\xa
in your path.
Link program
.obj
with the following libraries shown in Table D-3:
Run program
.exe
.
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, you must add either an environmental variable or a registry variable to the Windows 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.
Adding 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 affects all sessions on your Windows computer. This is useful for computers where only one TP monitor is running.
Go to the computer where your TP monitor is installed.
Enter the following at the command prompt:
C:\> regedt32
The Registry Editor window appears.
Go to HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME
ID
.
Choose the Add Value option in the Edit menu. The Add Value dialog box appears.
Enter ORA_XA_REG_DLL
in the Value Name text box.
Select REG_EXPAND_SZ
from the Datatype list box.
Choose OK. The String Editor dialog box appears.
Type vendor
.dll
in the String field, where vendor
.dll
is the TP monitor DLL provided by your vendor.
Choose OK. The Registry Editor adds the parameter.
Choose Exit from the Registry menu.
The registry exits.
Refer to the following general information about XA and TP monitors:
Distributed TP: The XA Specification (C193) published by the Open Group. The Open Group, 1010 El Camino Real, Suite 380, Menlo Park, CA 94025, U.S.A.
See the Web site at:
Your specific TP monitor documentation
See Also: Oracle Database Application Developer's Guide - Fundamentals "Developing Applications with Oracle XA", for more information about the Oracle XA Library and using XA dynamic registration |
The Object Type Translator (OTT) is used to create C struct representations of objects that have been created and stored in a 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.
Note: The INTYPE File Assistant is not available, starting with Oracle Database 10g Release 1. |
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 TYPE
or 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.
OTT on Windows can be invoked from the command line. Additionally, a configuration file may be named on the command line. For Windows, the configuration file is ottcfg.cfg,
located in ORACLE_BASE\ORACLE_HOME
\precomp\admin
.