Skip Headers
Oracle® Database Administrator's Reference
10g Release 1 (10.1) for UNIX Systems: AIX-Based Systems, Apple Mac OS X, hp HP-UX, hp Tru64 UNIX, Linux, and Solaris Operating System
Part No. B10812-06
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

6 Using Oracle Precompilers and the Oracle Call Interface

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


Note:

To use the demonstrations described in this chapter, you must install the Oracle Database Examples included on the Oracle Database 10g Companion CD.

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 Oracle Database 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 6-1 lists the names of the configuration files for each precompiler.

Table 6-1 System Configuration Files for Oracle Precompilers

Product Configuration File
Pro*C/C++ pcscfg.cfg
Pro*COBOL (AIX, HP-UX, Linux x86, Solaris SPARC, Tru64 UNIX, and zSeries Linux only) pcbcfg.cfg
Pro*FORTRAN (AIX, HP-UX, Solaris, Tru64 UNIX) pccfor.cfg
Object Type Translator ottcfg.cfg
SQL*Module for Ada (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 executable

This command creates the new executable in the $ORACLE_HOME/precomp/lib directory, and then moves it to the $ORACLE_HOME/bin directory.

In the preceding example, executable is a product executable listed in Table 6-2.

Table 6-2 Products and Their Corresponding Executable

Product Executable
Pro*C/C++ proc
Pro*COBOL (AIX, HP-UX, Linux x86, Solaris SPARC, Tru64 UNIX, and zSeries Linux) procob or rtsora
Pro*COBOL 32-bit (AIX, HP-UX PA-RISC, Solaris SPARC, and zSeries Linux) procob32 or rtsora32
Pro*FORTRAN (AIX, HP-UX, Solaris, and Tru64 UNIX only) profor
Pro*FORTRAN 32-bit (HP-UX only) profor32
SQL*Module for Ada (AIX only) modada

Precompiler README Files

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

Table 6-3 Location of Precompiler README Files

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

Issues Common to All Precompilers

The following issues are common to all precompilers.

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 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 or OCCI 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 space 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 and Static Libraries

The client shared and static libraries are located in the $ORACLE_HOME/lib or $ORACLE_HOME/lib32 directories, depending on your platform. If you use the Oracle provided demo_product.mk make file to link an application, the client shared library is linked by default.

If the shared library path environment variable setting for your platform does not include the directory that contains the client shared library, you might see an error message similar to one of the following when starting an executable:

Cannot load library libclntsh.a
Can't open shared library: .../libclntsh.sl.10.1
libclntsh.so.10.1: can't open file: errno=2 
can't open library: .../libclntsh.dylib.10.1  
Cannot map libclntsh.so

To avoid these errors, set the shared library path environment variable for your platform to specify the appropriate directory. The following table shows the environment variable name and directory for each platform. If your platform supports both 32-bit and 64-bit applications, make sure that you specify the correct directory, depending on the application that you want to run.

Platform Environment Variable Sample Setting
AIX (64-bit applications) LIBPATH $ORACLE_HOME/lib
AIX (32-bit applications) LIBPATH $ORACLE_HOME/lib32
HP-UX (64-bit applications), Linux, Solaris, and Tru64 UNIX LD_LIBRARY_PATH $ORACLE_HOME/lib
zSeries Linux (31-bit applications) LD_LIBRARY_PATH $ORACLE_HOME/lib32
HP-UX (32-bit applications) SHLIB_PATH $ORACLE_HOME/lib32
Mac OS X DYLD_LIBRARY_PATH $ORACLE_HOME/lib

The client shared library is created automatically during installation. If you need to recreate it, follow these steps:

  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 the following command:

    $ $ORACLE_HOME/bin/genclntsh
    
    

HP-UX PA-RISC Only: Non-threaded Client Shared Library

On HP-UX PA-RISC, 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, use one of the following commands to build your OCI application:

  • For 32-bit applications:

    $ make -f demo_rdbms32.mk build_nopthread EXE=oci02 OBJS=oci02.o
    
    
  • For 64-bit applications:

    $ make -f demo_rdbms.mk build_nopthread EXE=oci02 OBJS=oci02.o
    
    

Bit-Length Support for Client Applications

The following table identifies the bit lengths (31-bit, 32-bit, or 64-bit) supported for client application on each platform:

Client Application Type Supported Platforms
32-bit only Linux x86, Mac OS X, and Solaris x86
64-bit only Linux Itanium and Tru64 UNIX
32-bit and 64-bit AIX, HP-UX, and Solaris SPARC
31-bit and 64-bit zSeries Linux

On AIX, HP-UX, Solaris SPARC, and zSeries Linux, all demonstrations and client applications provided with Oracle Database 10g release 1 (10.1) link and run in 64-bit mode. However, on AIX, HP-UX, and Solaris SPARC, you can build 32-bit and 64-bit client applications in the same Oracle home directory. Similarly, on zSeries Linux, you can build 31-bit and 64-bit client applications in the same Oracle home directory.

The following table lists the 32-bit (or 31-bit) and 64-bit client shared libraries for these platforms:

Platform 32-Bit (or 31-Bit) Client Shared Library 64-Bit Client Shared Library
AIX
$ORACLE_HOME/lib32/libclntsh.a
$ORACLE_HOME/lib32/libclntsh.so
$ORACLE_HOME/lib/libclntsh.a
$ORACLE_HOME/lib/libclntsh.so
HP-UX PA-RISC
$ORACLE_HOME/lib32/libclntsh.sl
$ORACLE_HOME/lib/libclntsh.sl
HP-UX Itanium, Solaris SPARC, and zSeries Linux
$ORACLE_HOME/lib32/libclntsh.so
Note: On zSeries Linux, the $ORACLE_HOME/lib32 directory contains 31-bit libraries.
$ORACLE_HOME/lib/libclntsh.so

To implement a mixed word-size installation:

  1. To generate the 32-bit (or 31-bit on zSeries Linux) and 64-bit client shared libraries, enter the following command:

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

    Platform Environment Variable
    AIX LIBPATH
    HP-UX (32-bit client applications) SHLIB_PATH
    HP-UX, Solaris SPARC, and zSeries Linux LD_LIBRARY_PATH

Building 32-Bit Pro*C and OCI Customer Applications

On platforms that support both 32-bit and 64-bit Pro*C and Oracle Call Interface (OCI) customer applications, you can find more information about building 32-bit Pro*C and OCI applications in the following files:

For information about... See the Following Make Files:
Building 32-bit Pro*C applications $ORACLE_HOME/precomp/demo/proc/demo_proc32.mk
Building 32-bit OCI applications $ORACLE_HOME/rdbms/demo/demo_rdbms32.mk

AIX, HP-UX, Solaris SPARC, and zSeries Linux Only: 32-Bit Executables and Libraries

On platforms that support both 32-bit and 64-bit applications, the $ORACLE_HOME/bin directory contains both 32-bit and 64-bit executables. On these platforms, the following directories contain 32-bit 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:

For information about supported compiler versions for each platform, see the Oracle Database Installation Guide. For more information about the Pro*C/C++ precompiler and interface features, see the Pro*C/C++ Precompiler Programmer's Guide.

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 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.

To run, the programs require the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script to exist in the SCOTT schema with the password TIGER.


Note:

You must unlock the SCOTT account and set the password before creating the demonstrations.

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:


Note:

On AIX systems only, to ensure that the demonstration programs compile correctly, specify the -r option to the make command in the following examples. For example:
$ make -r -f demo_proc.mk sample1

$ 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 appears 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_proc.mk sample9 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 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, depending on your platform. On some platforms, you can also use the demo_proc32.mk make file to build 32-bit (or 31-bit) user programs. The following table shows the make files that you can use to build 32-bit (or 31-bit) and 64-bit user programs with Pro*C/C++ on each platform:

Platform 64-bit Make File 32-Bit Make File
AIX, HP-UX, and Solaris SPARC demo_proc.mk demo_proc32.mk
Linux x86, Mac OS X, and Solaris x86 Not applicable demo_proc.mk
Linux Itanium and Tru64 UNIX demo_proc.mk Not applicable
zSeries Linux demo_proc.mk demo_proc32.mk

Note: This make file builds 31-bit user programs.



Note:

For more information about creating user programs, see the make file.

To create a program using the demo_proc.mk make file, enter a command similar to the following:


Note:

On AIX systems only, to ensure that your programs compile correctly, specify the -r option to the make command in the following examples.

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

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, enter 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, enter:

    $ make -f demo_proc.mk build OBJS=myprog.o EXE=myprog
    
    
  • For C source, statically linked with the client shared library, 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 with the client shared library, enter:

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

Pro*COBOL Precompiler


Note:

Pro*COBOL is not supported on Linux Itanium, Mac OS X, or Solaris x86.

Table 6-4 shows the naming conventions for the Pro*COBOL precompiler.

Table 6-4 Pro*COBOL Naming Conventions

Item Naming Convention
Executable procob or procob32
Demonstration Directory procob2
Make file demo_procob.mk or demo_procob_32.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 (or the rtsora32 executable for 32-bit COBOL compilers) located in the $ORACLE_HOME/bin directory.

Pro*COBOL Environment Variables

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

Acucorp ACUCOBOL-GT COBOL Compiler

To use the Acucorp ACUCOBOL-GT COBOL compiler, you must set the A_TERMCAP, A_TERM, PATH, and LD_LIBRARY_PATH environment variables. If the LD_LIBRARY_PATH environment variable setting does not include the correct directory, an error message similar to the following appears when you compile or run a program:

runcbl: error while loading shared libraries: libclntsh.so.10.1: 
cannot open shared object file: No such file or directory

A_TERMCAP and A_TERM Set the A_TERMCAP environment variable to specify the location of the a_termcap file and set the A_TERM environment variable to specify a supported terminal from that file, for example:

  • Bourne, Bash, or Korn shell:

    $ A_TERMCAP=/opt/COBOL/etc/a_termcap
    $ A_TERM=vt100
    $ export A_TERMCAP A_TERM
    
    
  • C shell:

    % setenv A_TERMCAP /opt/COBOL/etc/a_termcap
    % setenv A_TERM vt100
    
    

PATH Set the PATH environment variable to include the /opt/COBOL/bin directory (or the /opt/COBOL31/bin directory if you are using the 31-bit compiler on zSeries Linux systems):

  • Bourne, Bash, or Korn shell:

    $ PATH=/opt/COBOL/bin:$PATH
    $ export PATH
    
    
  • C shell:

    % setenv PATH opt/COBOL/bin:${PATH}
    
    

LD_LIBRARY_PATH Set the LD_LIBRARY_PATH environment variable to the directory where the compiler library is installed. For example, if the compiler library is installed in the /opt/COBOL/lib directory, enter:

  • Bourne, Bash, or Korn shell:

    $ LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/COBOL/lib
    $ export LD_LIBRARY_PATH
    
    
  • C shell:

    % setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:/opt/COBOL/lib
    
    

Micro Focus Server Express COBOL Compiler

To use the Micro Focus Server Express COBOL compiler, you must set the COBDIR and PATH environment variables and the appropriate shared library path environment variable for your platform. The following table shows the appropriate shared library path environment variable for each platform:

Platform Environment Variable
AIX LIBPATH
HP-UX (32-bit client applications) SHLIB_PATH
HP-UX, Linux, Solaris SPARC, and zSeries Linux LD_LIBRARY_PATH

If the shared library path environment variable setting does not include the $COBDIR/coblib directory, an error message similar to the following appears when you compile or run a program:

  • On Linux:

    rtsora: error while loading shared libraries: libcobrts_t.so: 
    cannot open shared object file: No such file or directory
    
    
  • On Tru64 UNIX:

    356835:rtsora: /sbin/loader: Fatal Error: 
    Cannot map library libcobrts64_t.so.2 
    
    
  • On AIX, HP-UX PA-RISC, and Solaris SPARC:

    ld.so.1: rts32: fatal: libfhutil.so.2.0: Can't open file: errno=2
    
    
  • On HP-UX Itanium:

    /usr/lib/hpux64/dld.so: Unable to find library 'libcobrts64_t.so.2'.
    Killed
    
    

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

  • Bourne, Bash, or Korn shell:

    $ COBDIR=/opt/lib/cobol
    $ export COBDIR
    
    
  • C shell:

    % setenv COBDIR /opt/lib/cobol
    
    

PATH Set the PATH environment variable to include the $COBDIR/bin directory:

  • Bourne, Bash, or Korn shell:

    $ PATH=$COBDIR/bin:$PATH
    $ export PATH
    
    
  • C shell:

    % setenv PATH ${COBDIR}/bin:${PATH}
    
    

Shared Library Path Set the LIBPATH, LD_LIBRARY_PATH, or SHLIB_PATH environment variable to the directory where the compiler library is installed. For example, if your platform uses the LD_LIBRARY_PATH environment variable and the compiler library is installed in the $COBDIR/coblib directory, enter:

  • Bourne, Bash, or Korn shell:

    $ LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$COBDIR/coblib
    $ export LD_LIBRARY_PATH
    
    
  • C shell:

    % setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$COBDIR/coblib
    
    

Pro*COBOL Oracle Runtime System

Oracle provides its own complete runtime system, called rtsora (or rtsora32 for 32-bit COBOL compilers on 64-bit systems) to run dynamically loadable Pro*COBOL programs. Use the rtsora (or rtsora32) runtime system instead of the cobrun runtime system to run dynamically loadable Pro*COBOL programs. If you attempt to run a Pro*COBOL program with cobrun, you see an error message similar to the following:

$ 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 the $ORACLE_HOME/precomp/demo/procob2 directory. By default, all programs are dynamically linked with the client shared library.

To run the programs, the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script must exist in the SCOTT schema with the password TIGER.


Note:

You must unlock the SCOTT account and set the password before creating the demonstrations.

Use the following make file to create the demonstration programs:

$ORACLE_HOME/precomp/demo/procob2/demo_procob.mk

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 appears 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 required SQL scripts, enter:

$ make -f demo_procob.mk samples RUNSQL=run

Pro*COBOL User Programs

You can use the $ORACLE_HOME/precomp/demo/procob2/demo_procob.mk make file to create user programs. This make file builds either 32-bit or 64-bit user programs, depending on your platform. On some platforms, you can also use the demo_procob_32.mk make file to build 32-bit (or 31-bit) user programs. The following table shows the make files that you can use to build 32-bit (or 31-bit) and 64-bit user programs with Pro*COBOL on each platform:

Platform 64-bit Make File 32-Bit Make File
AIX, HP-UX, and Solaris SPARC demo_procob.mk demo_procob_32.mk
Linux x86 Not applicable demo_procob.mk
Tru64 UNIX demo_procob.mk Not applicable
zSeries Linux demo_procob.mk demo_procob_32.mk

Note: This make file builds 31-bit user programs.



Note:

For more information about creating user programs, see the make file.

To create a program using the demo_procob.mk make file, enter a command similar to the following:

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

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, enter 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, 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, (or rtsora32 for 32-bit COBOL compilers) 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 value 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 the value TERMINAL, columns 1 to 6 are dropped, making column 7 the left-most column.

Pro*FORTRAN Precompiler


Note:

Pro*FORTRAN is not supported on Linux, Mac OS X, or Solaris x86.

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


See Also:

For information about supported compiler versions for each platform, see the Oracle Database Installation Guide. For more information about the Pro*FORTRAN precompiler and interface features, see the Pro*FORTRAN Precompiler Programmer's Guide.

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.

To run the programs, the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script must exist in the SCOTT schema with the password TIGER.


Note:

You must unlock the SCOTT account and set the password before creating the demonstrations.

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 appears 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 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. This make file builds either 32-bit or 64-bit user programs, depending on your platform. On some platforms, 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 on each platform:

Platform 64-bit Make File 32-Bit Make File
AIX, HP-UX, and Solaris SPARC demo_procob.mk demo_procob_32.mk
Tru64 UNIX demo_procob.mk Not applicable


Note:

For more information about creating user programs, see the make file.

To create a program using the demo_proc.mk make file, enter a command similar to the following:

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

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, 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
    
    

AIX Only: SQL*Module for Ada

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


See Also:

For more information about required compiler versions, see the Oracle Database Installation Guide for UNIX Systems. For more information about SQL*Module for Ada, see the SQL*Module for Ada Programmer's Guide.

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.

To run the ch1_drv demonstration program the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script must exist in the SCOTT schema with the password TIGER.


Note:

You must unlock the SCOTT 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.

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 require 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. To create a user program with the demo_modada.mk make file, enter a command similar to the following:

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

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


    See Also:

    For more information about SQL*Module for Ada user programs, see the SQL*Module for Ada Programmers Guide.

Oracle Call Interface and Oracle C++ Call Interface

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.


See Also:

For more information about supported compiler versions for each platform, see the Oracle Database Installation Guide. For more information about OCI and OCCI, see the Oracle Call Interface Programmer's Guide or the Oracle C++ Call Interface Programmer's Guide.

OCI and OCCI Demonstration Programs

Demonstration programs that show the features of OCI and OCCI are provided. 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.

To run the demonstration programs, the demonstration tables created by the $ORACLE_HOME/sqlplus/demo/demobld.sql script must exist in the SCOTT schema with the password TIGER.


Note:

You must unlock the SCOTT account and set the password before creating the demonstrations.

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 OCCI, enter:

$ make -f demo_rdbms.mk c++demos

OCI and OCCI User Programs

You can use the $ORACLE_HOME/rdbms/demo/demo_rdbms.mk make file to create user programs. This make file builds either 32-bit or 64-bit user programs, depending on your platform. On some platforms, you can also use the demo_rdbms32.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 on each platform:

Platform 64-bit Make File 32-Bit Make File
AIX, HP-UX, and Solaris SPARC demo_rdbms.mk demo_rdbms32.mk
Linux x86, Mac OS X, and Solaris x86 Not applicable demo_rdbms.mk
Linux Itanium and Tru64 UNIX demo_rdbms.mk Not applicable
zSeries Linux demo_rdbms.mk demo_rdbms32.mk

Note: This make file builds 31-bit user programs.



Note:

For more information about creating user programs, see the make file.

To create a program using the demo_rdbms.mk make file, enter a command similar to the following:

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

  • 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
    
    

AIX, HP-UX, Solaris SPARC, and zSeries Linux Only: Oracle JDBC/OCI Programs With a 64-Bit Driver


Note:

You can also use the instructions and make files described in this section to create your own JDBC/OCI user programs that use a 64-bit driver.

To run JDBC/OCI demonstration programs with a 64-bit driver, follow these steps:

  1. Add $ORACLE_HOME/jdbc/lib/ojdbc14.jar to the start of the CLASSPATH environment variable for each of the following files:

    jdbc/demo/samples/jdbcoci/Makefile
    jdbc/demo/samples/generic/Inheritance/Inheritance1/Makefile
    jdbc/demo/samples/generic/Inheritance/Inheritance2/Makefile
    jdbc/demo/samples/generic/Inheritance/Inheritance3/Makefile
    jdbc/demo/samples/generic/JavaObject1/Makefile
    jdbc/demo/samples/generic/NestedCollection/Makefile
    
    
  2. In the $ORACLE_HOME/jdbc/demo/samples/generic/Makefile file, modify the JAVA and JAVAC variables to specify the JDK location as follows, depending on your platform:

    • Solaris SPARC and HP-UX:

      Change JAVA and JAVAC to the following, specifying the -d64 flag:

      JAVA=${ORACLE_HOME}/java/bin/java -d64
      JAVAC=${ORACLE_HOME}/java/bin/javac -d64
      
      
    • AIX and zSeries Linux:

      Change JAVA and JAVAC to the following, where JDK14_HOME is the directory in which the 64-bit JDK is installed:

      JAVA=$(JDK14_HOME)/bin/java
      JAVAC=$(JDK14_HOME)/bin/javac
      
      
  3. In the jdbc/demo/samples/generic/Makefile file, replace all occurrences of JDK14_HOME/bin/javac with JAVAC, and all occurrences of JDK14_HOME/bin/java with JAVA, except where JAVA and JAVAC are defined.

  4. Set the shared library path environment variable for your platform to include the $ORACLE_HOME/lib directory:

    Platform Environment Variable
    AIX LIBPATH
    HP-UX and zSeries Linux LD_LIBRARY_PATH
    Solaris SPARC LD_LIBRARY_PATH_64

Custom Make Files

Oracle recommends that you use the provided demo_product.mk make files 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, the following restrictions apply:

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:

$ 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/10.1.0/bin/symfind sqlcex
Local Directory: /u01/app/oracle/product/10.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

Oracle Database uses signals for two-task communication. Signals are installed in a user process when it 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
SIGCLD The pipe driver uses SIGCLD, also referred to as SIGCHLD, when an Oracle process terminates. 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 it applies only 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 6-1 shows how to set up a signal routine and a catching routine.

Example 6-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 6-2 shows how to use the osnsui() and the osncui() routines in an application program.

Example 6-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 bidirectional 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).

Oracle Database XA calls are defined in both the client shared library (libclntsh.a, libclntsh.sl, libclntsh.so, or libclntsh.dylib depending on your platform) and the client static library (libclntst10.a). These libraries are located in the $ORACLE_HOME/lib directory.