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-15
Targeting Example for C: Using Build Subdirectory
that the compiled SQL plans are read from empcnt_test.exe 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 at compile-time.
Targeting Example for C: Using 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 C
example, the same source file empcnt.sql is built twice using an OSS shell script
named empcnt.sh:
•
Set up class MAP DEFINEs. Then set up an OSS environmental 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
mxsqlc empcnt.sql -c $TableSet/empcnt.c \
-m $TableSet/empcnt.m \
-g moduleTableSet=$TableSet
c89 –o ./$TableSet/empcnt.o ./$TableSet/empcnt.c
nld –set systype oss \
-obey /usr/lib/libc.obey \
/usr/lib/crtlmain.o\
./$TableSet/empcnt.o \
-l zcplsrl \
-l zcrtlsrl \
-l zcresrl \
-l zcplosrl \
-l ztlhgsrl \
-l ztlhosrl \
-Bdynamic \
-l zclisrl \
-o ./$TableSet/empcnt.exe
/G/system/system/mxcmp ./$TableSet/empcnt.m