OpenTP1 Version 7 User's Guide

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

4.6.1 Linking with HiRDB

This subsection explains the settings required to link with HiRDB.

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

(1) Registering HiRDB

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

The following shows an example of the trnlnkrm command for HiRDB Version 8:

trnlnkrm -a HiRDB_DB_SERVER -s pdtxa_switch -o pdcltx32.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 manual Scalable Database Server HiRDB Version 7 Installation and Design Guide, for Windows systems.

The following notes explain execution of the trnlnkrm command.

(2) Specifying environment variables

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

The following shows an example of a transaction service definition:

putenv PDHOST host1
putenv PDNAMEPORT 22200
putenv PDTMID smpl
putenv PDSWAITTIME 6000

The following shows an example of a user service definition or user service default definition:

putenv PDHOST host1
putenv PDNAMEPORT 22200
putenv PDTMID smpl
putenv PDSWAITTIME 6000
putenv PDUSER '"root"/"root"'
putenv PDXAMODE 1
Note
Many of the errors that occur when a database is accessed from OpenTP1 while using the X/Open XA interface are due to invalid settings of environment variables (such as PDHOST and PDNAMEPORT). If the KFCA00901-W message is issued, check the settings of environment variables and revise them as necessary.

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 HiRDB and the manual Scalable Database Server HiRDB Version 7 UAP Development Guide, for Windows systems.

(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 HiRDB, specify the -n option and, if necessary, the -d option in the trnstring definition command.

There is no need to specify the xa_open and xa_close function strings (specified in the -o, -O, -c, and -C options in the trnstring definition command).

The following shows an example of a transaction service definition:

trnstring -n HiRDB_DB_SERVER

(4) Compiling and linking UAPs

When you compile and link a UAP that accesses HiRDB, 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 Scalable Database Server HiRDB Version 7 UAP Development Guide, for Windows systems. 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 HiRDB in C language and in COBOL.

In C language
trnmkobj -o rm_obj -r HiRDB_DB_SERVER

In COBOL
trnmkobj -o rm_obj -C "/Zl" -r HiRDB_DB_SERVER

(5) 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
HIRDBLIB = pdcltx32.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.ec
        $(PDDIR)\client\utl\pdcpp /XA $?
# 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) $(HIRDBLIB) 

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

(6) 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
HIRDBLIB = pdcltx32.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.ecb
        $(PDDIR)\client\utl\pdcbl /XA $?
exprocb2.cbl:exprocb2.ecb
        $(PDDIR)\client\utl\pdcbl /XA $?
# 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) $(HIRDBLIB)

#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) Notes about linking HiRDB