- 6 Using Oracle Precompilers and the Oracle Call Interface
- 6.1 Overview of Oracle Precompilers
- 6.1.1 Precompiler Configuration Files
- 6.1.2 Relinking Precompiler Executables
- 6.1.3 Precompiler README Files
- 6.1.4 Issues Common to All Precompilers
- 6.1.5 Static and Dynamic Linking
- 6.1.6 Client Shared and Static Libraries
- 6.2 Bit-Length Support for Client Applications
- 6.3 Pro*C/C++ Precompiler
- 6.3.1 Pro*C/C++ Demonstration Programs
- 6.3.2 Pro*C/C++ User Programs
- 6.4 Pro*COBOL Precompiler
- 6.4.1 Pro*COBOL Environment Variables
- 6.4.1.1 Micro Focus Server Express COBOL Compiler
- 6.4.1.2 Acucorp ACUCOBOL-GT COBOL Compiler
- 6.4.2 Pro*COBOL Oracle Runtime System
- 6.4.3 Pro*COBOL Demonstration Programs
- 6.4.4 Pro*COBOL User Programs
- 6.4.5 FORMAT Precompiler Option
- 6.5 Pro*FORTRAN Precompiler
- 6.5.1 Pro*FORTRAN Demonstration Programs
- 6.5.2 Pro*FORTRAN User Programs
- 6.6 SQL*Module for ADA
- 6.6.1 SQL*Module for Ada Demonstration Programs
- 6.6.2 SQL*Module for Ada User Programs
- 6.7 OCI and OCCI
- 6.7.1 OCI and OCCI Demonstration Programs
- 6.7.2 OCI and OCCI User Programs
- 6.8 Oracle JDBC/OCI Programs with a 64-Bit Driver
- 6.9 Custom Make Files
- 6.10 Correcting Undefined Symbols
- 6.11 Multithreaded Applications
- 6.12 Using Signal Handlers
- 6.13 XA Functionality
6 Using Oracle Precompilers and the Oracle Call Interface
This chapter describes how to use Oracle precompilers and the Oracle Call Interface. It contains the following sections:
To use the demonstrations described in this chapter, install the Oracle Database Examples included on the Oracle Database 11 g Examples media.
6.1 Overview of Oracle Precompilers
Oracle precompilers are application development tools that are used to combine SQL statements for an Oracle Database with programs written in a high-level language. Oracle precompilers are compatible with ANSI SQL and are used to develop and open customized applications that run with Oracle Database or any other ANSI SQL database management system.
This section contains the following topics:
ORACLE_HOME in this section refers to ORACLE_HOME that is created while installing Oracle Database Client 11 g by using the Administrator Install type.
6.1.1 Precompiler Configuration Files
Configuration files for the Oracle precompilers are located in the $ORACLE_HOME/precomp/admin directory.
Table 6-1 lists the names of the configuration files for each precompiler.
Table 6-1 System Configuration Files for Oracle Precompilers
Product | Configuration File | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product | Executable | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Precompiler | README File | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Platform | Environment Variable | Sample Setting |
---|---|---|
AIX (32-bit applications) | LIBPATH | $ORACLE_HOME/lib |
AIX (64-bit applications) | LIBPATH | $ORACLE_HOME/lib |
HP-UX (32-bit applications) | SHLIB_PATH | $ORACLE_HOME/lib |
HP-UX (64-bit applications) and Linux | LD_LIBRARY_PATH | $ORACLE_HOME/lib |
Solaris (32-bit applications) | LD_LIBRARY_PATH | $ORACLE_HOME/lib |
Solaris (64-bit applications) | LD_LIBRARY_PATH | $ORACLE_HOME/lib |
IBM: Linux on System z (32-bit applications) | LD_LIBRARY_PATH | $ORACLE_HOME/lib |
IBM: Linux on System z (64-bit applications) | LD_LIBRARY_PATH | $ORACLE_HOME/lib |
The client shared library is created automatically during installation. If you must re-create it, then:
Quit all client applications that use the client shared library, including all Oracle client applications such as SQL*Plus and Oracle Recovery Manager.
Log in as the oracle user, and run the following command:
Nonthreaded Client Shared Library
The information in this section applies to HP-UX systems.
On HP-UX, you can use a non-threaded client shared library. However, you cannot use this library with any OCI application that uses or has a dependency on threads.
To use this library for applications that do not use threads, run the following command to build the OCI application for 32 and 64-bit:
6.2 Bit-Length Support for Client Applications
The following table identifies the bit lengths (31-bit, 32-bit, or 64-bit) supported for client applications:
Starting with Oracle Database 11 g Release 2 (11.2), 32-bit precompiler, 32-bit client executables, and libraries are not available in the 64-bit Oracle database installation. These are installed as part of the Oracle Database Client Installation.
Client Application Type | Supported Platforms |
---|---|
32-bit only | Linux x86 |
32-bit and 64-bit | AIX, HP-UX PA-RISC, Linux x86-64, SPARC, HP-UX Itanium, Solaris x86-64, and IBM: Linux on System z |
The following table lists the 32-bit and 64-bit client shared libraries:
Starting with Oracle Database 11 g Release 2 (11.2), 32-bit and 64-bit Oracle Database Clients are installed in separate Oracle homes.
Platform | 32-Bit (or 31-Bit) Client Shared Library | 64-Bit Client Shared Library |
---|---|---|
AIX | ||
HP-UX PA-RISC |
To implement a mixed word-size installation:
Run the following command to generate the 32-bit and 64-bit client shared libraries:
Include the paths of the required 32-bit and 64-bit client shared libraries in one of the following environment variables, depending on the platform:
Platform | Environment Variable |
---|---|
AIX | LIBPATH |
HP-UX (32-bit client applications) | SHLIB_PATH |
HP-UX, Linux x86, Linux x86-64, Solaris, and IBM: Linux on System z | LD_LIBRARY_PATH |
Building 32-Bit Pro*C and OCI Customer Applications
If the operating system supports both Pro*C and Oracle Call Interface (OCI) customer applications, then you can find more information about building Pro*C and OCI applications in the following files:
For Information About. . . | Refer to the Following Make Files. . . |
---|---|
Building Pro*C applications | $ORACLE_HOME/precomp/demo/proc/demo_proc.mk |
Building OCI applications | $ORACLE_HOME/rdbms/demo/demo_rdbms.mk |
6.3 Pro*C/C++ Precompiler
Before you use the Pro*C/C++ precompiler, verify that the correct version of the operating system compiler is properly installed.
Oracle Database Installation Guide for information about supported compiler versions
Pro*C/C++ Programmer’s Guide for information about the Pro*C/C++ precompiler and interface features
This section contains the following topics:
6.3.1 Pro*C/C++ Demonstration Programs
Demonstration programs are provided to show the features of the Pro*C/C++ precompiler. There are three types of demonstration programs: C, C++, and Object programs. All demonstration programs are located in the $ORACLE_HOME/precomp/demo/proc directory. By default, all programs are dynamically linked with the client shared library.
To run the demonstration programs, the programs require the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script to exist in the JONES schema with a password.
You must unlock the JONES account and set the password before creating the demonstrations.
Use the demo_proc.mk make file, which is located in the $ORACLE_HOME/precomp/demo/proc/ directory, to create the demonstration programs. For example, to precompile, compile, and link the sample1 demonstration program, run the following command:
On AIX systems, to ensure that the demonstration programs compile correctly, include the -r option of the make command in the following examples. For example:
To create all the C demonstration programs for Pro*C/C++, run the following command:
To create all the C++ demonstration programs for Pro*C/C++, run the following command:
To create all the Object demonstration programs for Pro*C/C++, run the following command:
Some demonstration programs require you to run a SQL script, located in the $ORACLE_HOME/precomp/demo/sql directory. If you do not run the script, then a message prompting you to run it is displayed.
To build a demonstration program and run the corresponding SQL script, include the make macro argument RUNSQL=run at the command line. For example, to create the sample9 demonstration program and run the required $ORACLE_HOME/precomp/demo/sql/sample9.sql script, run the following command:
To create all the Object demonstration programs and run all the required SQL scripts, run the following command:
6.3.2 Pro*C/C++ User Programs
You can use the $ORACLE_HOME/precomp/demo/proc/demo_proc.mk make file to create user programs. This make file builds either 32-bit or 64-bit user programs. You can also use the demo_proc32.mk make file to build 32-bit user programs. The following table shows the make files that you can use to build 32-bit and 64-bit user programs with Pro*C/C++:
Platform | 64-bit Make File | 32-Bit Make File |
---|---|---|
AIX, HP-UX, Linux x86-64, Solaris x86-64 and Solaris | demo_proc.mk | demo_proc32.mk |
Linux x86 | NA | demo_proc.mk |
The make file for more information about creating user programs
On AIX systems, to ensure that the programs compile correctly, specify the -r option for the make command used in the following examples.
To create a program by using the demo_proc.mk make file, run a command similar to the following:
In this example:
target is the make file target that you want to use
objfilen is the object file to link the program
exename is the executable program
For example, to create the program myprog from the Pro*C/C++ source file myprog.pc , run one of the following commands, depending on the source and the type of executable that you want to create:
For C source dynamically linked with the client shared library, run the following command:
For C source statically linked with the client shared library, run the following command:
For C++ source dynamically linked with the client shared library, run the following command:
For C++ source statically linked with the client shared library, run the following command:
6.4 Pro*COBOL Precompiler
Table 6-4 shows the naming conventions for the Pro*COBOL precompiler.
Table 6-4 Pro*COBOL Naming Conventions
Item | Naming Convention | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Platform | Make File |
---|---|
AIX, HP-UX, Linux x86-64, Solaris, IBM: Linux on System z, and Linux x86 | demo_procob.mk |
The make file for more information about creating user programs
To create a program using the demo_procob.mk make file, run a command similar to the following:
In this example:
target is the make file target that you want to use
cobfilen is the COBOL source file for the program
exename is the executable program
For example, to create the program myprog , run one of the following commands, depending on the source and type of executable that you want to create:
For COBOL source, dynamically linked with the client shared library, run the following command:
For COBOL source, statically linked, run the following command:
For COBOL source, dynamically loadable for use with rtsora , run the following command:
6.4.5 FORMAT Precompiler Option
The FORMAT precompiler option specifies the format of input lines for COBOL. If you specify the default value ANSI , then columns 1 to 6 contain an optional sequence number, column 7 indicates comments or continuation lines, paragraph names begin in columns 8 to 11, and statements begin in columns 12 to 72.
If you specify the value TERMINAL , then columns 1 to 6 are dropped, making column 7 the left most column.
6.5 Pro*FORTRAN Precompiler
Before you use the Pro*FORTRAN precompiler, verify that the correct version of the compiler is installed. This section contains the following topics:
Oracle Database Installation Guide for information about supported compiler versions
Pro*FORTRAN Supplement to the Oracle Precompilers Guide for information about the Pro*FORTRAN precompiler and interface features
6.5.1 Pro*FORTRAN Demonstration Programs
Demonstration programs are provided to show the features of the Pro*FORTRAN precompiler. All demonstration programs are located in the $ORACLE_HOME/precomp/demo/profor directory. By default, all programs are dynamically linked with the client shared library.
To run the demonstration programs, the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script must exist in the JONES schema with a password.
You must unlock the JONES account and set the password before creating the demonstrations.
To create the demonstration programs, use the demo_profor.mk make file, located in the $ORACLE_HOME/precomp/demo/profor directory. For example, to precompile, compile, and link the sample1 demonstration program, run the following command:
To create the Pro*FORTRAN demonstration programs, run the following command:
Some demonstration programs require you to run a SQL script that is located in the $ORACLE_HOME/precomp/demo/sql directory. If you do not run the script, then a message prompting you to run it is displayed.
To build a demonstration program and run the corresponding SQL script, include the make macro argument RUNSQL=run on the command line. For example, to create the sample11 demonstration program and run the required $ORACLE_HOME/precomp/demo/sql/sample11.sql script, run the following command:
To create the Pro*FORTRAN demonstration programs and run all the required SQL scripts, run the following command:
6.5.2 Pro*FORTRAN User Programs
You can use the $ORACLE_HOME/precomp/demo/profor/demo_profor.mk make file to create user programs. This make file builds either 32-bit or 64-bit user programs. You can also use the demo_profor_32.mk make file to build 32-bit user programs. The following table shows the make files that you can use to build 32-bit and 64-bit user programs with Pro*FORTRAN:
Platform | 64-bit Make File | 32-Bit Make File |
---|---|---|
AIX, HP-UX, and Solaris | demo_profor.mk | demo_profor_32.mk |
The make file for more information about creating user programs
To create a program using the demo_proc.mk make file, run a command similar to the following:
In this example:
target is the make file target that you want to use
forfilen is the FORTRAN source for the program
exename is the executable program
For example, to create the program myprog from the Pro*FORTRAN source file myprog.pfo , run one of the following commands, depending on the type of executable that you want to create:
For an executable dynamically linked with the client shared library, run the following command:
For an executable statically linked with the client shared library, run the following command:
6.6 SQL*Module for ADA
The information in this section applies to the AIX platform.
Before using SQL*Module for Ada, verify that the correct version of the compiler is installed.
Oracle Database Installation Guide for information about required compiler versions
This section contains the following topics:
6.6.1 SQL*Module for Ada Demonstration Programs
Demonstration programs are provided to show the features of SQL*Module for Ada. All demonstration programs are located in the $ORACLE_HOME/precomp/demo/modada directory. By default, all programs are dynamically linked with the client shared library.
To run the ch1_drv demonstration program, the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script must exist in the JONES schema with a password.
You must unlock the JONES account and set the password before creating the demonstrations.
The demcalsp and demohost demonstration programs require that the sample college database exists in the MODTEST schema. You can use the appropriate make command to create the MODTEST schema and load the sample college database.
Run the following command to create the SQL*Module for Ada demonstration programs, run the necessary SQL scripts to create the MODTEST user, and create the sample college database:
To create a single demonstration program ( demohost ) and run the necessary SQL scripts to create the MODTEST user, and create the sample college database, run the following command:
To create the SQL*Module for Ada demonstration programs, without re-creating the sample college database, run the following command:
To create a single demonstration program ( demohost ), without re-creating the sample college database, run the following command:
To run the programs, you must define an Oracle Net connect string or alias named INST1_ALIAS that is used to connect to the database where the appropriate tables exist.
6.6.2 SQL*Module for Ada User Programs
You can use the $ORACLE_HOME/precomp/demo/modada/demo_modada.mk make file to create user programs. To create a user program with the demo_modada.mk make file, run a command similar to the following:
In this example:
modulen is a compiled Ada object
exename is the executable program
SQL_Module_arguments are the command-line arguments to be passed to the SQL*Module
6.7 OCI and OCCI
Before you use the Oracle Call Interface (OCI) or Oracle C++ Call Interface (OCCI), verify that the correct version of C or C++ is installed.
Oracle Database Installation Guide for information about supported compiler versions
This section contains the following topics:
6.7.1 OCI and OCCI Demonstration Programs
Demonstration programs that show the features of OCI and OCCI are provided with the software through the Oracle Database 11 g Examples media. There are two types of demonstration programs: C and C++. All demonstration programs are located in the $ORACLE_HOME/rdbms/demo directory. By default, all programs are dynamically linked with the client shared library.
To run the demonstration programs, the programs require the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script to exist in the JONES schema with a password. Some demonstration programs require specific .sql files to be run, as mentioned in the demonstration source files. OCCI demonstration programs require occidemo.sql to be run.
You must unlock the JONES account and set the password before creating the demonstrations.
Use the demo_rdbms.mk make file, which is located in the $ORACLE_HOME/rdbms/demo directory, to create the demonstration programs. For example, to compile and link the cdemo1 demonstration program, run the following command:
To create the C demonstration programs for OCI, run the following command:
To create the C++ demonstration programs for OCCI, run the following command:
6.7.2 OCI and OCCI User Programs
You can use the $ORACLE_HOME/rdbms/demo/demo_rdbms.mk make file to build user programs. This make file builds either 32-bit or 64-bit user programs. You can also use the demo_rdbms32.mk to build 32-bit user programs on a 64-bit operating system. The following table shows the make files that you can use to build 32-bit and 64-bit user programs with Pro*FORTRAN:
Platform | 64-bit Make File | 32-Bit Make File |
---|---|---|
AIX, HP-UX, Solaris, and Linux x86-64 | demo_rdbms.mk | demo_rdbms32.mk |
Linux x86 | NA | demo_rdbms.mk |
The make file for more information about building user programs
6.8 Oracle JDBC/OCI Programs with a 64-Bit Driver
The information in this section applies to AIX, HP-UX, Linux x86-64, and Solaris platforms.
You can use the instructions and make files described in this section to create JDBC/OCI user programs that use a 64-bit driver.
To run JDBC/OCI demonstration programs with a 64-bit driver:
Add $ORACLE_HOME/jdbc/lib/ojdbc5.jar to the start of the CLASSPATH environment variable value for each of the following files:
In the $ORACLE_HOME/jdbc/demo/samples/generic/Makefile file, modify the JAVA and JAVAC variables to specify the JDK location and the -d64 flag as follows:
Set the LD_LIBRARY_PATH_64 environment variable to include the $ORACLE_HOME/lib directory.
On AIX, the LIBPATH variable is the LD_LIBRARY_PATH_64 variable equivalent. You must use the LIBPATH variable on AIX instead of the LD_LIBRARY_PATH_64 variable.
6.9 Custom Make Files
Oracle recommends that you use the demo_ product .mk make files provided with the software to create user programs as described in the product-specific sections of this chapter. If you modify the provided make file or if you choose to use a custom-written make file, then remember that the following restrictions apply:
Do not modify the order of the Oracle libraries. Oracle libraries are included on the link line more than once so that all the symbols are resolved during linking.
Except for AIX, the order of the Oracle libraries is essential on all platforms for the following reasons:
Oracle libraries are mutually referential. For example, functions in library A call functions in library B, and functions in library B call functions in library A.
The HP-UX linkers are one-pass linkers. The AIX, Linux, and Solaris linkers are two-pass linkers.
Add the library to the beginning or to the end of the link line. Do not place user libraries between the Oracle libraries.
If you choose to use a make utility such as nmake or GNU make , then you must be aware of how macro and suffix processing differs from the make utility provided with the operating system. Oracle make files are tested and supported with the make utility.
Oracle library names and the contents of Oracle libraries are subject to change between releases. Always use the demo_ product .mk make file that ships with the current release as a guide to determine the required libraries.
6.10 Correcting Undefined Symbols
Oracle provides the symfind utility to assist you in locating a library or object file where a symbol is defined. When linking a program, undefined symbols are a common error that produce an error message similar to the following:
The error occurs when the linker cannot find a definition for a referenced symbol. If this error message is displayed, then verify that the library or object file containing the definition exists on the link line and that the linker is searching the correct directories for the file.
The following example shows the output from the symfind utility, which is used to locate the sqlcex symbol:
6.11 Multithreaded Applications
The Oracle libraries provided with this release are thread-safe, they support multithreaded applications.
6.12 Using Signal Handlers
Oracle Database uses signals for two-task communication. Signals are installed in a user process when the process connects to the database and are removed when it disconnects.
Table 6-5 describes the signals that Oracle Database uses for two-task communication.
Table 6-5 Signals for Two-Task Communication
Signal | Description |
---|---|