Oracle9i Administrator's Reference Release 1 (9.0.1) for UNIX Systems: AIX-Based Systems, Compaq Tru64 UNIX, HP 9000 Series HP-UX, Linux Intel and Sun SPARC Solaris Part Number A90347-02 |
|
This chapter describes Oracle Precompilers and the Oracle Call Interface. It contains the following sections:
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.
System configuration files for the Oracle Precompilers are located in the $ORACLE_HOME/precomp/admin
directory. Table 4-1 lists the names of the system configuration files for each precompiler.
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-3 lists the location of the precompiler README files. The README files describe changes made to the precompiler since the last release.
The following issues are common to all precompilers.
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.
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.
The IRECLEN and ORECLEN parameters do not have maximum values.
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:
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 used by default.
You might receive the following error message when starting an executable:
$ sample1 ld.so.1: sample1: fatal: libclntsh.so.1.0: can't open file: errno=2 Killed
If you receive this error message, set the LD_LIBRARY_PATH environment variable as follows:
$ LD_LIBRARY_PATH=$ORACLE_HOME/lib:${LD_LIBRARY_PATH} $ export LD_LIBRARY_PATH
The client shared library is created automatically during installation. If you must recreate the client shared library:
oracle
user and enter:
$ genclntsh
You might receive the following error message when starting an executable:
$ sample1
exec(): 0509-036 Cannot load program ./sample1 because of the following
errors:
0509-022 Cannot load library libclntsh.sl
[shr.0]
0509-026 System error: A file or directory in the pathname does not exist.
If you receive this error message, set the LIBPATH environment variable as follows:
$ LIBPATH=$ORACLE_HOME/lib:${LIBPATH} $ export LIBPATH
The client shared library is created automatically during installation. If you must recreate the client shared library:
oracle
user and enter:
$ genclntsh
You might receive the following error message when starting an executable:
$ sample1 /sbin/loader: Fatal Error: Cannot map libclntsh.so Killed
If you receive this error message, set the LD_LIBRARY_PATH environment variable as follows:
$ LD_LIBRARY_PATH=$ORACLE_HOME/lib:${LD_LIBRARY_PATH} $ export LD_LIBRARY_PATH
The client shared library is created automatically during installation. If you must recreate the client shared library:
oracle
user and enter:
$ genclntsh
You might receive the following error message when starting an executable:
$ sample1 /usr/lib/dld.sl: Can't open shared library: /u01/app/oracle/product/9.0.1/lib/libclntsh.sl.8.0 /usr/lib/dld.sl: No such file or directory Abort (core dumped)
If you receive this error message, set the SHLIB_PATH environment variable as follows:
$ SHLIB_PATH=$ORACLE_HOME/lib:${SHLIB_PATH} $ export SHLIB_PATH
The client shared library is created automatically during installation. If you must recreate the client shared library:
oracle
user and enter:
$ cd $ORACLE_HOME/rdbms/lib
$ make -f ins_rdbms.mk libclntsh.sl
Before you use the Pro*C/C++ precompiler, verify that the correct version of the operating system compiler is properly installed.
.
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
See Also:
For information on using SQL*Plus to create the demonstration tables, see "Using Demonstration Tables". |
You can use the $ORACLE_HOME/precomp/demo/proc/demo_proc.mk
make file to create user programs. The syntax for linking 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:
build)
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.
$ make -f demo_proc.mk build OBJS=myprog.o EXE=myprog
$ make -f demo_proc.mk build_static OBJS=myprog.o EXE=myprog
$ make -f demo_proc.mk cppbuild OBJS=myprog.o EXE=myprog
$ make -f demo_proc.mk cppbuild_static OBJS=myprog.o EXE=myprog
There are two versions of Pro*COBOL included with this release. Table 4-4 shows the naming conventions for each version.
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.
This section describes the environment variables required by Pro*COBOL.
For the Merant Server Express COBOL compiler, you must set the COBDIR and LD_LIBRARY_PATH environment variables.
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
The LD_LIBRARY_PATH environment variable must include the $COBDIR/coblib
directory. To add this directory to the LD_LIBRARY_PATH environment variable, enter:
$ LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$COBDIR/coblib $ export LD_LIBRARY_PATH
If the LD_LIBRARY_PATH environment variable setting does not include the $COBDIR/coblib
directory, one of the following error messages appears when you compile a program:
14783 rtspra: /sbin/loader: Fatal Error: cannot map libwtc8.so
ld.so.1: rts32: fatal: libfhutil.so.2.0: can't open file: errno=2
For the Sun Nihongo COBOL compiler, you must set the PATH and LD_LIBRARY_PATH environment variables.
Set the PATH environment variable to include the /opt/SUNWnsun/bin
directory, as follows:
$ PATH ${PATH}:/opt/SUNWnsun/bin
$ export PATH
The LD_LIBRARY_PATH environment variable must include the /opt/SUNWnsun/bin
directory. To add this directory to the LD_LIBRARY_PATH environment variable, enter:
$ 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
If you are using Sun Nihongo COBOL, you might want to rename the make files to match the examples and create a backup copy of the files, as follows:
$ cd $ORACLE_HOME/precomp/demo/procob2 $ mv demo_procob.mk demo_procob.mk.mf $ cp demo_procob.mk.nsun demo_procob.mk
$ cd $ORACLE_HOME/precomp/demo/procob $ mv demo_procob18.mk demo_procob18.mk.mf $ cp demo_procob18.mk.nsun demo_procob18.mk
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
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:
$ORACLE_HOME/precomp/demo/procob/demo_procob.mk
$ORACLE_HOME/precomp/demo/procob/demo_procob18.mk
To precompile, compile, and link the sample1
demonstration program for ProCOBOL, 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
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 linking a program with the demonstration make file is:
$ make -f demo_procob.mk target COBS="cobfile1 cobile2 ..." EXE=exename
$ make -f demo_procob18.mk target COBS="cobfile1 cobfile2 ..." EXE=
In the preceding examples:
build)
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:
$ make -f demo_procob.mk build COBS=myprog.cob EXE=myprog
$ make -f demo_procob.mk build_static COBS=myprog.cob EXE=myprog
rtsora
, enter:
$ make -f demo_procob.mk myprog.gnt
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.
Before you use the Pro*FORTRAN precompiler, verify that the correct version of the compiler is installed.
.
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
You can use the $ORACLE_HOME/precomp/demo/profor/demo_profor.mk
make file to create user programs. The syntax for linking 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:
build)
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:
$ make -f demo_profor.mk build FORS=myprog.f EXE=myprog
$ make -f demo_profor.mk build_static FORS=myprog.f EXE=myprog
Before using SQL*Module for Ada, verify that the correct version of the compiler is installed.
.
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.
Use the $ORACLE_HOME/precomp/demo/modada
/demo_modada.mk
make file to create user programs. The syntax for linking 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:
Before you use the Oracle Call Interface (OCI), verify that the correct version of Pro*C/C++ is installed.
.
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 $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
You can use the $ORACLE_HOME/rdbms/demo
/demo_rdbms.mk
make file to create programs. The syntax for linking a user program with demo_rdbms.mk
is:
$ make -f demo_rdbms.mk target OBJS="objfile1 objfile2 ..." EXE=exename
In the preceding example:
build)
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:
$ make -f demo_rdbms.mk build OBJS=myprog.o EXE=myprog
$ make -f demo_rdbms.mk build_static OBJS=myprog.o EXE=myprog
$ make -f demo_rdbms.mk buildc++ OBJS=myprog.o EXE=myprog
$ make -f demo_rdbms.mk buildc++_static OBJS=myprog.o EXE=myprog
Oracle Corporation recommends that you use the provided demo_
product
.mk
make files to link 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:
The order of the Oracle libraries is essential for the following reasons:
nmake
or GNU make
, be aware of how macro and suffix processing differs from the make utility provided with the platform. Oracle make files are tested and are supported with the make
utility for your platform.
demo_
product
.mk
make file that ships with the current release as a guide to determine the required libraries.
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.0.1/bin/symfind sqlcex
Local Directory: /u01/app/oracle/product/9.0.1
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
The Oracle libraries provided with this release are thread safe, allowing support for multi-threaded applications.
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.
The listed signals affect Pro*C and all other 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.
/* 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.
/* ** 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. */ ... } ... }
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.
|
![]() Copyright © 2001 Oracle Corporation. All Rights Reserved. |
|