OpenTP1 Version 7 User's Guide

[Contents][Index][Back][Next]

4.6.2 Linking with Oracle

This subsection explains the settings required to link with Oracle.

Organization of this subsection
(1) Registering Oracle
(2) Specifying environment variables
(3) Specifying the transaction service definition
(4) Settings required for accessing multiple Oracle databases
(5) Compiling and linking UAPs
(6) Example of a makefile (in C language)
(7) Example of a makefile (for COBOL)
(8) Notes about linking Oracle

(1) Registering Oracle

You must register Oracle in the OpenTP1 system. Use the trnlnkrm command to do this.

The following shows an example of the trnlnkrm command for Oracle Database 11g:

trnlnkrm -a Oracle_XA -s xaosw -o oraxa11.lib

For details about the trnlnkrm command, see Chapter 7. Operation Commands. For details about the information to be specified in the trnlnkrm command, such as RM name, RM switch name, and RM-related object name, see the Oracle documentation.

The following notes explain execution of the trnlnkrm command.

(2) Specifying environment variables

You must set appropriate values in the Oracle environment variables in order to access Oracle. Specify the environment variables in putenv format in the following OpenTP1 system definitions:

The following shows an example of these definitions:

putenv ORACLE_HOME c:\orant
putenv ORACLE_SID ORCL

For details about the OpenTP1 system definition, see Chapter 5. System Definitions. For details about the environment variables to be specified and their settings, see the settings used for installing Oracle and the Oracle documentation.

(3) Specifying the transaction service definition

Use the trnstring transaction service definition command to specify the information required in order to access the resource manager. When you link OpenTP1 with Oracle, specify the -n, -o, and -O options and, if necessary, the -d option in the trnstring definition command.

Specify in the -o and -O options the xa_open function string used to access the resource manager. There is no need to specify the xa_close function string (specified in the -c and -C options in the trnstring definition command).

For uid in the xa_open function string for the transaction service that is specified in the -o option, specify the Oracle database administrator. If the specified uid does not belong to the Oracle database administrator or the specified uid does not have the DBA privilege, partial UAP recovery processing or transaction recovery processing after an OpenTP1 system restart might not be performed successfully. For details about the xa_open function string to be specified in Oracle, see the Oracle documentation.

The following shows an example of a transaction service definition:

trnstring -n Oracle_XA \
-o "Oracle_XA+Acc=P/sys/change_on_install+SesTm=60" \
-O "Oracle_XA+Acc=P/scott/tiger+SesTm=60"

Note
If a character string enclosed in double quotation marks (") continues onto the next line following a continuation line symbol (\), make sure that the specification on the continuation line begins in column 1.

Note
Many of the errors that occur when an Oracle database is accessed from OpenTP1 while using the X/Open XA interface are due to an invalid xa_open function string definition. If the KFCA00901-W message is issued, check the xa_open function string definition and revise it as necessary.

(4) Settings required for accessing multiple Oracle databases

This subsection explains the settings required in order to access multiple Oracle databases from OpenTP1. These settings also apply when a single Oracle database is accessed using multiple Oracle uids.

(5) Compiling and linking UAPs

When you compile and link a UAP that accesses Oracle, you must use the trnmkobj command to link the transaction control object created under %DCDIR%\spool\trnrmcmd\userobj.

For details about how to compile and link UAPs, see 3.2 Compiling and linking UAPs, the edition of the manual OpenTP1 Programming Reference for the applicable language, and the Oracle documentation. For details about the trnmkobj command, see Chapter 7. Operation Commands.

The following shows examples of creating a transaction control object for UAPs that access Oracle in C language and in COBOL.

In C language

trnmkobj -o rm_obj -r Oracle_XA

In COBOL

trnmkobj -o rm_obj -C "/Zl" -r Oracle_XA

(6) Example of a makefile (in C language)

This subsection presents an example of a makefile that is used when an SPP is created in C language.

(a) Source file names

The source file names used in the example makefile are as follows:

(b) Example of a makefile

The following shows an example of a makefile:

NODEBUG = 1
!include <ntwin32.mak>
#TP1TEST Make File
SYSLIB = $(conlibsdll)
TP1LIB = [libdam.lib]#1 [libtam.lib]#2 libbetran.lib
ORACLELIB = oraxa11.lib
 
all:TP1TEST.exe
# Compile
exmain.obj:exmain.c
        $(cc) $(cflags) $(cvarsdll) $*.c
exsv1.obj:exsv1.c
        $(cc) $(cflags) $(cvarsdll) $*.c
exsv2.obj:exsv2.c
        $(cc) $(cflags) $(cvarsdll) $*.c
ex_sstb.obj:ex_sstb.c
        $(cc) $(cflags) $(cvarsdll) $*.c
exproc.obj:exproc.c
        $(cc) $(cflags) $(cvarsdll) $*.c
# Create a stub source file
ex_sstb.c:ex.def
        $(DCDIR)\bin\stbmake $?
# Precompile
exproc.c:exproc.pc
        $(ORACLE_HOME)\bin\proc release_cursor=yes $?
# Link
TP1TEST.exe: exmain.obj exsv1.obj exsv2.obj ex_sstb.obj exproc.obj
        $(link) $(conflags) -out:$*.exe $** \
        [$(DCDIR)\spool\trnrmcmd\userobj\rm_obj.obj \]#3
        $(TP1LIB) $(SYSLIB) $(ORACLELIB)

#1
Specify libdam.lib only if you use TP1/FS/Direct Access.

#2
Specify libtam.lib only if you use TP1/FS/Table Access.

#3
If you use TP1/FS/Direct Access or TP1/FS/Table Access, add OpenTP1_DAM or OpenTP1_TAM when you use the trnmkobj command to create a transaction control object.

(7) Example of a makefile (for COBOL)

This subsection presents an example of a makefile that is used when an SPP is created in COBOL.

(a) Source file names

The source file names used in the example makefile are as follows:

(b) Example of a makefile

The following shows an example of a makefile:

!include <ntwin32.mak>
#TP1TEST Make File
CBLFG1 = -Compile,NoLink -Comp5 -Lib,CUI -SQL,ODBC -Main,System
CBLFG2 = -Compile,NoLink -Comp5 -Lib,CUI -SQL,ODBC
SYSLIB = $(conlibsdll)
TP1LIB = [libdam.lib]#1 [libtam.lib]#2 libbetran.lib
ORACLELIB = oraxa11.lib
CCBL = ccbl2002
LK = ccbl2002 -Lib,CUI
 
all:TP1TEST.exe
# Compile
main.obj:main.cbl
        $(CCBL) $(CBLFG1) main.cbl
sev1.obj:sev1.cbl
        $(CCBL) $(CBLFG2) sev1.cbl
sev2.obj:sev2.cbl
        $(CCBL) $(CBLFG2) sev2.cbl
exprocb1.obj:exprocb1.cbl
        $(CCBL) $(CBLFG2) exprocb1.cbl
exprocb2.obj:exprocb2.cbl
        $(CCBL) $(CBLFG2) exprocb2.cbl
ex_sstb.obj:ex_sstb.c
        $(cc) $(cflags) /Zl $(cvarsdll) $*.c
# Create a stub source file
ex_sstb.c:ex.def
        $(DCDIR)\bin\stbmake $?
# Precompile
exprocb1.cbl:exprocb1.pco
        $(ORACLE_HOME)\bin\procob release_cursor=yes $?
exprocb2.cbl:exprocb2.pco
        $(ORACLE_HOME)\bin\procob release_cursor=yes $?
# Link
TP1TEST.exe: main.obj sev1.obj sev2.obj ex_sstb.obj \
             exprocb1.obj exprocb2.obj
        $(LK) -OutputFile $*.exe $** \
        [$(DCDIR)\spool\trnrmcmd\userobj\rm_obj.obj \]#3
        $(TP1LIB) $(SYSLIB) $(ORACLELIB)

#1
Specify libdam.lib only if you use TP1/FS/Direct Access.

#2
Specify libtam.lib only if you use TP1/FS/Table Access.

#3
If you use TP1/FS/Direct Access or TP1/FS/Table Access, add OpenTP1_DAM or OpenTP1_TAM when you use the trnmkobj command to create a transaction control object.

(8) Notes about linking Oracle