SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Program and Module Management
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
17-18
Targeting Example for COBOL: Using a Build
Subdirectory
Because a module-tableset-specification-string is specified, the
module file produced by the SQL/MX compiler is:
/usr/tandem/sqlmx/USERMODULES/CAT.SCH.^EMP_CNT_MODULE^PROD^
After building the application for both sets of tables, the user can execute either
compiled executable and its corresponding compiled SQL.
When the empcnt_test.exe is run for the first set of tables, the user must again set
up DEFINEs =DEPT to reference \TEST.$DATA.HR1.DEPT and =EMPLOYEE to
reference \TEST.$DATA.HR1.EMPLOYEE.
The other set of tables is targeted if the user runs empcnt_prod.exe and sets up
DEFINEs =DEPT to reference \PROD.$DATA.HR1.DEPT and =EMPLOYEE to
reference \PROD.$DATA.HR1.EMPLOYEE.
You can set up DEFINEs to reference the production environment set of tables and
then use the empcnt_test.exe executable (or vice versa). The result of this action is
that the compiled SQL plans are read from module:
/usr/tandem/sqlmx/USERMODULES/CAT.SCH.^EMP_CNT_MODULE^TEST^.
These plans refer to the test environment tables, \TEST.$DATA.HR1.DEPT and
\TEST.$DATA.HR1.EMPLOYEE. However, the SQL/MX executor performs late name
resolution (see Late Name Resolution on page 8-6). Because the run-time tables
(specified by setting up the DEFINEs for the production system) are different from the
compile-time tables, the executor performs a similarity check. If the two sets of tables
are similar, the plan is used. If the two set of tables are dissimilar, the plan is
recompiled. The advantage of compile-time name resolution is lost if DEFINEs are set
differently at run time than they were set at compile-time.
Targeting Example for COBOL: Using a Build Subdirectory
To avoid the problem where intermediate files and even the executable can be
overwritten when rebuilding for a new target, use OSS environment variables. In this
COBOL example, the same source file empcnt.ecbl is built twice using an OSS shell
script named empcnt.sh.
•
Set up class MAP DEFINEs. Then set up an OSS environment variable,
TableSet, to supply both a module-tableset-specification-string and
the name of a subdirectory to which the intermediate files (including the” before-
link object file) and executable can be written.
export TableSet=TEST
add_define =DEPT class=MAP file=\\TEST.\$DATA.HR1.DEPT
add_define =EMPLOYEE class=MAP
file=\\TEST.\$DATA.HR1.EMPLOYEE
•
Invoke the shell script empcnt.sh. The shell script includes the lines:
mkdir ./$TableSet
mxsqlco empcnt.ecbl -c $TableSet/empcnt.cbl \
-m $TableSet/empcnt.m \