Skip Headers

Oracle9i Administrator's Reference
Release 2 (9.2.0.1.0) for UNIX Systems: AIX-Based Systems, Compaq Tru64 UNIX, HP 9000 Series HP-UX, Linux Intel, and Sun Solaris
Part No. A97297-01
Go To Table Of Contents
Contents
Go To Index
Index

Previous Next

4
Using Oracle Precompilers and the Oracle Call Interface

This chapter describes Oracle Precompilers and the Oracle Call Interface. It contains the following sections:

Overview of Oracle Precompilers

Oracle precompilers are application-development tools 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 open, customized applications that run with Oracle9i or any other ANSI SQL database management system.

Precompiler Configuration Files

Configuration files for the Oracle precompilers are located in the $ORACLE_HOME/precomp/admin directory. Table 4-1 lists the names of the configuration files for each precompiler.

Table 4-1 System Configuration Files for Oracle Precompilers

Product Configuration File
Pro*C/C++ release 9.2.0.1.0 pcscfg.cfg
Pro*COBOL release 9.2.0.1.0 (AIX, HP, Solaris, and Tru64 only) pcbcfg.cfg
Pro*COBOL release 1.8.77.0.0 (AIX, HP, Solaris, and Tru64 only) pcccob.cfg
Pro*FORTRAN release 1.8.77.0.0 (AIX, HP, Solaris, and Tru64 only) pccfor.cfg
Object Type Translator release 9.2.0.1.0 ottcfg.cfg
Oracle SQL*Module for Ada release 9.2.0.1.0 (Solaris 32-bit and AIX only) pmscfg.cfg

Relinking Precompiler Executables

Use the $ORACLE_HOME/precomp/lib/ins_precomp.mk make file to relink all precompiler executables. To manually relink a particular precompiler executable, enter the following command:

$ make -f ins_precomp.mk relink EXENAME=executable

This command creates the new executable in the $ORACLE_HOME/precomp/lib directory, and then moves it to the $ORACLE_HOME/bin directory. To create the new executable without moving it to the $ORACLE_HOME/bin directory, enter the following command:

$ make -f ins_precomp.mk executable

In the preceding examples, executable is a product executable listed in Table 4-2.

Table 4-2 Products and Their Corresponding Executable

Product Executable
Pro*C/C++ release 9.2.0.1.0 proc
Pro*COBOL release 9.2.0.1.0 (AIX, HP, Solaris, and Tru64 only) procob or rtsora
Pro*COBOL release 1.8.77.0.0 (AIX, HP, Solaris, and Tru64 only) procob18 or rtsora
Pro*FORTRAN release 1.8.77.0.0 (AIX, HP, Solaris, and Tru64 only) profor
Object Type Translator release 9.2.0.1.0 ott
Oracle SQL*Module for Ada release 9.2.0.1.0 (Solaris 32-bit and AIX only) modada

Precompiler README Files

Table 4-3 lists the location of the precompiler README files. The README files describe changes made to the precompiler since the last release.

Table 4-3 Location of Precompiler README Files

Precompiler README File
Pro*C/C++ release 9.2.0.1.0 $ORACLE_HOME/precomp/doc/proc2/readme.doc
Pro*COBOL release 9.2.0.1.0 $ORACLE_HOME/precomp/doc/procob2/readme.doc
Pro*COBOL release 1.8.77.0.0 and Pro*FORTRAN release 1.8.77.0.0 $ORACLE_HOME/precomp/doc/pro1x/readme.txt

Issues Common to All Precompilers

The following issues are common to all precompilers.


Note:

To run Oracle Precompiler demonstrations, Oracle9i must already be installed.

Uppercase to Lowercase Conversion

In languages other than C, the compiler converts an uppercase function or subprogram name to lowercase. This can cause a ÒNo such user existsÓ error message. If you receive this error message, verify that the function or subprogram name in your option file matches the case used in the IAPXTB table.

Vendor Debugger Programs

Precompilers and vendor-supplied debuggers can be incompatible. Oracle Corporation does not guarantee that a program run using a debugger will perform the same way when it is run without the debugger.

Value of IRECLEN and ORECLEN

The IRECLEN and ORECLEN parameters do not have maximum values.

Static and Dynamic Linking

You can statically or dynamically link Oracle libraries with precompiler and OCI applications. With static linking, the libraries and objects of the whole application are linked together into a single executable program. As a result, application executables can become very large.

With dynamic linking, the executing code is partly stored in the executable program and partly stored in libraries that are linked dynamically by the application at runtime. Libraries that are linked at runtime are called dynamic or shared libraries. The benefits of dynamic linking are:

  • Smaller disk requirements—More than one application or invocation of the same application can use the same dynamic library.

  • Smaller main memory requirements—The same dynamic library image is loaded into main memory only once and it can be shared by more than one application.

Client Shared Library

The client shared library is located in the $ORACLE_HOME/lib directory. If you use the Oracle provided demo_product.mk make file to link an application, the client shared library is linked by default.

You might receive one of the following error message when starting an executable:

  • On AIX systems:

    $ sample1
    exec(): 0509-036 Cannot load program ./sample1 because of the following 
    errors:
    0509-022 Cannot load library libclntsh.a [shr.o]
    0509-026 System error: A file or directory in the pathname does not exist.
    
    
  • On HP systems:

    $ sample1
    /usr/lib/dld.sl: Can't open shared library:
    /u01/app/oracle/product/9.2.0.1.0/lib/libclntsh.sl.9.0
    /usr/lib/dld.sl: No such file or directory
    Abort (core dumped)
    
    
  • On Solaris and Linux systems:

    $ sample1
    ld.so.1: sample1: fatal: libclntsh.so.1.0: can't open file: errno=2 
    Killed
    
    
  • On Tru64 systems:

    $ sample1
    /sbin/loader: Fatal Error: Cannot map libclntsh.so
    Killed
    
    

If you receive one of these error messages, set one of the following environment variables, depending on your platform:

  • On AIX systems:

    $ LIBPATH=$ORACLE_HOME/lib:${LIBPATH}
    $ export LIBPATH
    
    
  • On HP systems (64-bit applications), Linux, Solaris, and Tru64 systems:

    $ LD_LIBRARY_PATH=$ORACLE_HOME/lib:${LD_LIBRARY_PATH}
    $ export LD_LIBRARY_PATH
    
    
  • On HP systems (32-bit applications)

    $ SHLIB_PATH=$ORACLE_HOME/lib32:${SHLIB_PATH}$ export SHLIB_PATH 
    
    

The client shared library is created automatically during installation. If you must recreate the client shared library:

  1. Exit all client applications that use the client shared library, including all Oracle client applications such as SQL*Plus and Recovery Manager.

  2. Log in as the oracle user and enter:

    $ genclntsh
    

Support for 32-Bit and 64-Bit Client Applications (AIX, HP, and Solaris 64-Bit Only)

Oracle9i release 2 (9.2.0.1.0) for AIX, HP, and Solaris 64-bit systems provides support for 32-bit and 64-bit client applications. By default, all demonstrations and client applications provided with release 2 (9.2.0.1.0) link and run in 64-bit mode. However, you can build 32-bit and 64-bit client applications in the same ORACLE home directory. You can run both 32-bit and 64-bit applications on Oracle9i release 2 (9.2.0.1.0) for AIX, HP, and Solaris 64-bit systems. The following table lists the 32-bit and 64-bit client shared libraries:

Platform 32-Bit Client Shared Library 64-Bit Client Shared Library
AIX $ORACLE_HOME/lib32/libclntsh.a $ORACLE_HOME/lib/libclntsh.a
HP $ORACLE_HOME/lib32/libclntsh.sl $ORACLE_HOME/lib/libclntsh.sl
Solaris 64-bit $ORACLE_HOME/lib32/libclntsh.so $ORACLE_HOME/lib/libclntsh.so

To implement a mixed word-size installation:

  1. Execute the following command to generate the 32-bit and 64-bit client shared libraries:

    $  genclntsh 
    
    
  2. Include the paths of the required 32-bit and 64-bit shared libraries in one of the following environment variables, depending on your platform:

    Platform Environment Variable
    AIX, Solaris 64-bit LIBPATH
    HP (32-bit client applications) SHLIB_PATH
    HP (64-bit client applications) LD_LIBRARY_PATH

Building 32-Bit Pro*C and OCI Customer Applications

Oracle9i release 2 (9.2.0.1.0) supports both 32-bit and 64-bit Pro*C and Oracle Call Interface (OCI) customer applications.


See Also:

$ORACLE_HOME/precomp/demo/demo_proc.mk and $ORACLE_HOME/precomp/demo/demo_proc32.mk files for information on building 32-bit Pro*C applications.

See the $ORACLE_HOME/rdbms/demo/demo_rdbms.mk and $ORACLE_HOME/rdbms/demo/demo_rdbms32.mk files for information on building 32-bit Pro*C applications.



32-Bit Executables and Directories (AIX and HP Only)

In Oracle9i release 2 (9.2.0.1.0) for HP and AIX systems, the following directories contain 32-bit executables and libraries:

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.


See Also:

Oracle9i Installation Guide Release 2 (9.2.0.1.0) for UNIX Systems for information on the required compiler versions on each platform, and the Pro*C/C++ Precompiler Programmer's Guide for additional information on the Pro*C/C++ precompiler and interface features.

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. Object programs demonstrate the new Oracle9i Object features. All of the demonstration programs are located in the $ORACLE_HOME/precomp/demo/proc directory. By default, all programs are dynamically linked with the client shared library.

The programs assume that the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script exist in the SCOTT schema with the password TIGER.

Use the demo_proc.mk make file, 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, enter the following command:

$ make -f demo_proc.mk sample1

To create all of the C demonstration programs for Pro*C/C++, enter:

$ make -f demo_proc.mk samples

To create all of the C++ demonstration programs for Pro*C/C++, enter:

$ make -f demo_proc.mk cppsamples

To create all of the Object demonstration programs for Pro*C/C++, enter:

$ make -f demo_proc.mk object_samples

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, a message displays requesting you to run it. 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 calldemo demonstration program and run the required $ORACLE_HOME/precomp/demo/sql/calldemo.sql script, enter:

$ make -f demo_proc.mk calldemo RUNSQL=run

To create all of the Object demonstration programs and run all corresponding required SQL scripts, enter:

$ make -f demo_proc.mk object_samples RUNSQL=run

Pro*C/C++ User Program

You can use the $ORACLE_HOME/precomp/demo/proc/demo_proc.mk make file to create user programs. The syntax for creating a program with the demo_proc.mk make file is:

$ make -f demo_proc.mk target OBJS="objfile1 objfile2 ..." EXE=exename

In the preceding 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, enter one of the following commands, depending on the source and the type of executable you want to create.

  • For C source, dynamically linked with the client shared library, enter:

    $ make -f demo_proc.mk build OBJS=myprog.o EXE=myprog
    
    
  • For C source, statically linked, enter:

    $ make -f demo_proc.mk build_static OBJS=myprog.o EXE=myprog
    
    
  • For C++ source, dynamically linked with the client shared library, enter:

    $ make -f demo_proc.mk cppbuild OBJS=myprog.o EXE=myprog
    
    
  • For C++ source, statically linked, enter:

    $ make -f demo_proc.mk cppbuild_static OBJS=myprog.o EXE=myprog
    
    

    Note:

    On AIX, HP, and Solaris 64-bit systems, the demo_proc.mk make file builds 64-bit user programs by default. You can also use the demo_proc32.mk make file to build 32-bit user programs. See the make file for more information on creating 32-bit user programs.

Pro*COBOL Precompiler (AIX, HP, Solaris, and Tru64 Only)

There are two versions of Pro*COBOL included with this release. Table 4-4 shows the naming conventions for each version.

Table 4-4 Pro*COBOL Naming Conventions

Item Pro*COBOL Release 9.2.0.1.0 Pro*COBOL Release 1.8.77.0.0
Executable procob procob18
Demonstration Directory procob2 procob
Make file for Merant Server Express COBOL demo_procob.mk demo_procob18.mk

Pro*COBOL supports statically linked, dynamically linked, or dynamically loadable programs. Dynamically linked programs use the client shared library. Dynamically loadable programs use the rtsora executable located in the $ORACLE_HOME/bin directory.

Pro*COBOL Environment Variables

This section describes the environment variables required by Pro*COBOL.

Merant Server Express COBOL Compiler

For the Merant Server Express COBOL compiler, you must set the COBDIR environment variable and the LD_LIBRARY_PATH, LIBPATH, or SHLIB_PATH environment variable, depending on your operating system.


COBDIR

Set the COBDIR environment variable to the directory where the compiler is installed. For example, if the compiler is installed in the /opt/cobol directory, enter:

$ COBDIR=${COBDIR}:$/opt/cobol 
$ export COBDIR


LD_LIBRARY_PATH (Solaris and HP with 64-Bit Applications Only)

Set the LD_LIBRARY_PATH environment variable to the directory where the compiler is installed. For example, if the compiler is installed in the $COBDIR/coblib directory, enter:

$ LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$COBDIR/coblib
$ export LD_LIBRARY_PATH


LIBPATH (AIX only)

Set the LIBPATH environment variable to the directory where the compiler is installed. For example, if the compiler is installed in the $COBDIR/coblib directory, enter:

$ LIBPATH=${LIBPATH}:$COBDIR/coblib
$ export LIBPATH


SHLIB_PATH (HP with 32-Bit Applications)

Set the SHLIB_PATH environment variable to the directory where the compiler is installed. For example, if the compiler is installed in the $COBDIR/coblib directory, enter:

$ SHLIB_PATH=${SHLIB_PATH}:$COBDIR/coblib
$ export SHLIB_PATH

If the LD_LIBRARY_PATH, LIBPATH, or SHLIB_PATH environment variable setting does not include the $COBDIR/coblib directory, one of the following error messages appears when you compile a program:

  • On Tru64:

    14783 rtsora: /sbin/loader: Fatal Error: cannot map libwtc9.so
    
    
  • On AIX, HP, and Solaris:

    ld.so.1: rts32: fatal: libfhutil.so.2.0: can't open file: errno=2
    
    

PATH

Set the PATH environment variable to include the /opt/SUNWnsun/bin directory, as follows:

$ PATH ${PATH}:/opt/SUNWnsun/bin 
$ export PATH


LD_LIBRARY_PATH

Set the LD_LIBRARY_PATH environment variable to include the /opt/SUNWnsun/bin directory, as follows:

$ LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/SUNWnsun/bin
$ export LD_LIBRARY_PATH

If the LD_LIBRARY_PATH environment variable setting does not include the /opt/SUNWnsun/bin directory, the following error message appears when you compile a program:

ld.so.1: cobol: fatal: liblicense.so: can't open file: errno=2

Pro*COBOL Oracle Runtime System

Oracle provides its own complete runtime system, called rtsora, to run dynamically loadable Pro*COBOL programs. Use the rtsora runtime system in place of the cobrun runtime system provided by Merant to run dynamically loadable Pro*COBOL programs. If you attempt to run a Pro*COBOL program with cobrun, you receive the following error:

$ cobrun sample1.gnt
Load error : file 'SQLADR'
error code: 173, pc=0, call=1, seg=0
173     Called program file not found in drive/directory

Pro*COBOL Demonstration Programs

Demonstration programs are provided to show the features of the Pro*COBOL precompiler. The demonstration programs are located in either the $ORACLE_HOME/precomp/demo/procob directory or the $ORACLE_HOME/precomp/demo/procob2 directory, depending on the Pro*COBOL version. By default, all programs are dynamically linked with the client shared library.

The programs assume that the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script exist in the SCOTT schema with the password TIGER.

Use the appropriate make file to create the demonstration programs:

  • For Pro*COBOL release 9.2.0.1.0, use:

    $ORACLE_HOME/precomp/demo/procob/demo_procob.mk
    
    
  • For Pro*COBOL release 1.8.77.0.0, use:

    $ORACLE_HOME/precomp/demo/procob/demo_procob18.mk
    
    

    Note:

    The following examples assume that you are using the make file for Pro*COBOL release 9.2.0.1.0.

To precompile, compile, and link the sample1 demonstration program for Pro*COBOL, enter:

$ make -f demo_procob.mk sample1

To create all of the Pro*COBOL demonstration programs, enter:

$ make -f demo_procob.mk samples

To create and run a dynamically loadable sample1.gnt program to be used with the rtsora runtime system, enter:

$ make -f demo_procob.mk sample1.gnt
$ rtsora sample1.gnt

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, a message displays requesting you to run it. 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 sample9 demonstration program and run the required $ORACLE_HOME/precomp/demo/sql/sample9.sql script, enter:

$ make -f demo_procob.mk sample9 RUNSQL=run

To create all of the Pro*COBOL demonstration programs and run all corresponding required SQL scripts, enter:

$ make -f demo_procob.mk samples RUNSQL=run

Pro*COBOL User Programs

You can use the appropriate demonstration make file to create user programs, depending on the version of Pro*COBOL you are using. The syntax for creating a program with the demonstration make file is:

  • For Pro*COBOL release 9.2.0.1.0, enter:

    $ make -f demo_procob.mk target COBS="cobfile1 cobile2 ..." EXE=exename
    
    
  • For Pro*COBOL release 1.8.77.0.0, enter:

    $ make -f demo_procob18.mk target COBS="cobfile1 cobfile2 ..." EXE=exename
    
    

In the preceding examples:

  • 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, enter one of the following commands, depending on the source and type of executable you want to create:

  • For COBOL source, dynamically linked with the client shared library, enter:

    $ make -f demo_procob.mk build COBS=myprog.cob EXE=myprog
    
    
  • For COBOL source, statically linked, enter:

    $ make -f demo_procob.mk build_static COBS=myprog.cob EXE=myprog
    
    
  • For COBOL source, dynamically loadable for use with rtsora, enter:

    $ make -f demo_procob.mk myprog.gnt
    
    

FORMAT Precompiler Option

The FORMAT precompiler option specifies the format of input lines for COBOL. If you specify the default FORMAT=ANSI, 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 FORMAT=TERMINAL, columns 1 to 6 are dropped, making column 7 the left-most column.

Pro*FORTRAN Precompiler (AIX, HP, Solaris, and Tru64 Only)

Before you use the Pro*FORTRAN precompiler, verify that the correct version of the compiler is installed.


See Also:

Oracle9i Installation Guide Release 2 (9.2.0.1.0) for UNIX Systems for information on the required compiler versions on each platform, and the Pro*FORTRAN Precompiler Programmer's Guide for additional information on the Pro*FORTRAN precompiler and interface features.

Pro*FORTRAN Demonstration Programs

Demonstration programs are provided to show the features of the Pro*FORTRAN precompiler. All of the demonstration programs are located in the $ORACLE_HOME/precomp/demo/profor directory. By default, all programs are dynamically linked with the client shared library.

The programs assume that the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script exist in the SCOTT schema with the password TIGER.

Use the demo_profor.mk make file, located in the $ORACLE_HOME/precomp/demo/profor directory, to create the demonstration programs. For example, to precompile, compile, and link the sample1 demonstration program, enter:

$ make -f demo_profor.mk sample1

To create all of the Pro*FORTRAN demonstration programs, enter:

$ make -f demo_profor.mk samples

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, a message displays requesting you to run it. 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, enter:

$ make -f demo_profor.mk sample11 RUNSQL=run

To create all of the Pro*FORTRAN demonstration programs and run all corresponding required SQL scripts, enter:

$ make -f demo_profor.mk samples RUNSQL=run

Pro*FORTRAN User Programs

You can use the $ORACLE_HOME/precomp/demo/profor/demo_profor.mk make file to create user programs. The syntax for creating a program with the demo_proc.mk make file is:

$ make -f demo_profor.mk target FORS="forfile1 forfile2 ..." EXE=exename

In the preceding 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, enter 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, enter:

    $ make -f demo_profor.mk build FORS=myprog.f EXE=myprog
    
    
  • For an executable statically linked, enter:

    $ make -f demo_profor.mk build_static FORS=myprog.f EXE=myprog
    
    

SQL*Module for Ada (Solaris 32-Bit and AIX Only)

Before using SQL*Module for Ada, verify that the correct version of the compiler is installed.


See Also:

Oracle9i Installation Guide Release 2 (9.2.0.1.0) for UNIX Systems for information on the required compiler versions on each platform, and the SQL*Module for Ada Programmer's Guide for additional information on SQL*Module for Ada.

SQL*Module for Ada Demonstration Programs

Demonstration programs are provided to show the features of SQL*Module for Ada. All of the demonstration programs are located in the $ORACLE_HOME/precomp/demo/modada directory. By default, all programs are dynamically linked with the client shared library.

The ch1_drv demonstration program assumes that the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script exist in the SCOTT schema with the password TIGER.

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.

To create all of the SQL*Module for Ada demonstration programs, run the necessary SQL scripts to create the MODTEST user, and create the sample college database, enter:

$ make -f demo_modada.mk all RUNSQL=run

To create a single demonstration program (demohost), and run the necessary SQL scripts to create the MODTEST user, and create the sample college database, enter:

$ make -f demo_modada.mk makeuser loaddb demohost RUNSQL=run

To create all of the SQL*Module for Ada demonstration programs, without recreating the sample college database, enter:

$ make -f demo_modada.mk samples

To create a single demonstration program (demohost), without recreating the sample college database, enter:

$ make -f demo_modada.mk demohost

All programs assume that an Oracle Net connect string or alias named INST1_ALIAS is defined and is capable of connecting to the database where the appropriate tables exist.

SQL*Module for Ada User Programs

You can use the $ORACLE_HOME/precomp/demo/modada/demo_modada.mk make file to create user programs. The syntax for creating a user program with the demo_modada.mk make file is:

$ make -f demo_modada.mk ada OBJS="module1 module2 ..." \
EXE=exename MODARGS=SQL*Module_arguments

In the preceding 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


    See Also:

    SQL*Module for Ada Programmers Guide for more information on SQL*Module for Ada user programs.

Oracle Call Interface

Before you use the Oracle Call Interface (OCI), verify that the correct version of Pro*C/C++ is installed.


See Also:

Oracle9i Installation Guide Release 2 (9.2.0.1.0) for UNIX Systems for more information on the required version of Pro*C/C++ for your operating system, and the Oracle Call Interface Programmer's Guide for additional information on the Oracle Call Interface.

OCI Demonstration Programs

Demonstration programs are provided that show the features of the OCI. There are two types of demonstration programs: C and C++. All of the demonstration programs are located in the $ORACLE_HOME/rdbms/demo directory. By default, all programs are dynamically linked with the client shared library.

Many of the demonstration programs assume that the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script exist in the SCOTT schema with the password TIGER.

Use the demo_rdbms.mk make file, located in the $ORACLE_HOME/rdbms/demo directory, to create the demonstration programs. For example, to compile and link the cdemo1 demonstration program, enter the following command:

$ make -f demo_rdbms.mk cdemo1

To create all of the C demonstration programs for OCI, enter:

$ make -f demo_rdbms.mk demos

To create all of the C++ demonstration programs for OCI, enter:

$ make -f demo_rdbms.mk c++demos

OCI User Programs

You can use the $ORACLE_HOME/rdbms/demo/demo_rdbms.mk make file to create user programs. The syntax for creating a user program with the demo_rdbms.mk make file is:

$ make -f demo_rdbms.mk target OBJS="objfile1 objfile2 ..." EXE=exename

In the preceding 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 myprog program from the C/C++ source myprog.c, enter one of the following commands, depending on the type of executable you want to create:

  • For C source, dynamically linked with the client shared library, enter:

    $ make -f demo_rdbms.mk build OBJS=myprog.o EXE=myprog
    
    
  • For C source, statically linked, enter:

    $ make -f demo_rdbms.mk build_static OBJS=myprog.o EXE=myprog
    
    
  • For C++ source, dynamically linked with the client shared library, enter:

    $ make -f demo_rdbms.mk buildc++ OBJS=myprog.o EXE=myprog
    
    
  • For C++ source, statically linked, enter:

    $ make -f demo_rdbms.mk buildc++_static OBJS=myprog.o EXE=myprog
    
    

    Note:

    In the preceding examples, the file myprog.o is the object file generated by the compiler.

    On AIX, HP, and Solaris 64-bit, the demo_rdbms.mk make file builds 64-bit user programs by default. You can use the demo_rdbms32.mk make file to build 32-bit user programs. See the make file for more information on creating 32-bit user programs.


Custom Make Files

Oracle Corporation recommends that you use the provided demo_product.mk make files to create user programs as described in the specific product sections of this chapter. If you modify the provided make file, or if you choose to use a custom-written make file, the following restrictions apply:

Correcting Undefined Symbols (Solaris Only)

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:

$ make -f demo_proc.mk sample1
Undefined                       first referenced
 symbol                             in file
sqlcex                              sample1.o
sqlglm                              sample1.o
ld: fatal: Symbol referencing errors. No output written to sample1

The error occurs when the linker cannot find a definition for a referenced symbol. If this error message occurs, ensure 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, used to locate the sqlcex symbol:

$ symfind sqlcex

SymFind - Find Symbol <sqlcex> in <**>.a, .o, .so
------------------------------------------------------
Command:         /u01/app/oracle/product/9.2.0.1.0/bin/symfind sqlcex
Local Directory: /u01/app/oracle/product/9.2.0.1.0
Output File:     (none)
Note:            I do not traverse symbolic links
                 Use '-v' option to show any symbolic links

Locating Archive and Object files ...
[11645] |    467572|      44|FUNC |GLOB |0    |8      |sqlcex
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ./lib/libclntsh.sl
[35]    |         0|      44|FUNC |GLOB |0    |5      |sqlcex
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ./lib/libsql.a

Multi-threaded Applications

The Oracle libraries provided with this release are thread safe, allowing support for multi-threaded applications.

Using Signal Handlers

Oracle9i uses signals for two-task communication. Signals are installed in a user process when you connect to the database and are removed when you disconnect.

Table 4-5 describes the signals that Oracle9i uses for two-task communication.

Table 4-5 Signals for Two-Task Communication

Signal Description
SIGCLD The pipe driver uses SIGCLD, also referred to as SIGCHLD, when an Oracle process dies. The UNIX kernel sends a SIGCLD signal to the user process. The signal handler uses the wait() routine to determine whether a server process died. The Oracle process does not catch SIGCLD; the user process catches it.
SIGCONT The pipe two-task driver uses SIGCONT to send out-of-band breaks from the user process to the Oracle process.
SIGINT Two-task drivers use SIGINT to detect user interrupt requests. The Oracle process does not catch SIGINT; the user process catches it.
SIGIO Oracle Net protocols use SIGIO to indicate incoming networking events.
SIGPIPE The pipe driver uses SIGPIPE to detect end-of-file on the communications channel. When writing to the pipe, if no reading process exists, a SIGPIPE signal is sent to the writing process. Both the Oracle process and the user process catch SIGPIPE. SIGCLD is similar to SIGPIPE, but only applies to user processes, not to Oracle processes.
SIGTERM The pipe driver uses SIGTERM to signal interrupts from the user to the Oracle process. This occurs when the user presses the interrupt key, Ctrl+c. The user process does not catch SIGTERM; the Oracle process catches it.
SIGURG Oracle Net TCP/IP drivers use SIGURG to send out-of-band breaks from the user process to the Oracle process.

The listed signals affect all precompiler applications. You can install one signal handler for SIGCLD (or SIGCHLD) and SIGPIPE when connected to the Oracle process. If you call the osnsui() routine to set it up, you can have more than one signal handle for SIGINT. For SIGINT, use osnsui() and osncui() to register and delete signal-catching routines.

You can also install as many signal handlers as you want for other signals. If you are not connected to the Oracle process, you can have multiple signal handlers.

Example 4-1 shows how to set up a signal routine and a catching routine.

Example 4-1 Signal Routine and Catching Routine

/* user side interrupt set */
word osnsui( /*_ word *handlp, void (*astp), char * ctx, _*/)
/*
** osnsui: Operating System dependent Network Set User-side Interrupt. Add an 
** interrupt handling procedure astp. Whenever a user interrupt(such as a ^C)
** occurs, call astp with argument ctx. Put in *handlp handle for this 
** handler so that it may be cleared with osncui. Note that there may be many
** handlers; each should be cleared using osncui. An error code is returned if
** an error occurs.
*/

/* user side interrupt clear */
word osncui( /*_ word handle _*/ );
/*
** osncui: Operating System dependent Clear User-side Interrupt. Clear the
** specified handler. The argument is the handle obtained from osnsui. An error
** code is returned if an error occurs.
*/

Example 4-2 shows how to use the osnsui() and the osncui() routines in an application program.

Example 4-2 osnsui() and osncui() Routine Template

/*
** User interrupt handler template.
*/
void sig_handler()
{
...
}

main(argc, argv)
int arc;
char **argv; 
{

        int handle, err;
        ...

        /* set up my user interrupt handler */

        if (err = osnsui(&handle, sig_handler, (char *) 0))
        {
                /* if the return value is non-zero, an error has occurred
                   Take appropriate action for the error. */
                ...
        }

        ...

        /* clear my interrupt handler */

        if (err = osncui(handle))
        {
                /* if the return value is non-zero, an error has occurred
                   Take appropriate action for the error. */
                ...
        }
        ...
}

XA Functionality

Oracle XA is the Oracle implementation of the X/Open Distributed Transaction Processing (DTP) XA interface. The XA standard specifies a bi-directional interface between resource managers (for example, Oracle) that provide access to shared resources within transactions, and between a transaction service that monitors and resolves transactions.

Oracle Call Interface has XA functionality. When building a TP-monitor XA application, ensure that the TP-monitor libraries (that define the symbols ax_reg and ax_unreg) are placed in the link line before the Oracle client shared library. This link restriction is required only when using the XA dynamic registration (Oracle XA switch xaoswd).

Oracle9i does not support Oracle7 release 7.1.6 XA calls (although it does support Oracle7 release 7.3 XA calls). Therefore, TP-monitor XA applications using Oracle7 release 7.1.6 XA calls must be relinked with the Oracle9i XA library. The Oracle9i XA calls are defined in both the $ORACLE_HOME/lib/libclntsh.sl shared library and the $ORACLE_HOME/lib/libclient9.a static library.


Previous Next
Oracle Logo
Copyright © 1996, 2002 Oracle Corporation

All rights reserved
Go To Table Of Contents
Contents
Go To Index
Index