SQL/MX 3.2.1 Programming Manual for C and COBOL (H06.26+, J06.15+)

Program and Module Management
HP NonStop SQL/MX Release 3.2.1 Programming Manual for C and COBOL663854-005
17-16
Targeting Example for C: Using ModuleTableSet
(MTSS)
2. Invoke the preprocessor, specifying a module-tableset-specification-
string with the -g option:
mxsqlc empcnt.sql -c empcnt.c -m empcnt.m \
-g moduleTableSet=TEST
3. The previous preprocessor step produces a pure C file (empcnt.c) and a module
definition file (empcnt.m). The c89 utility compiles and links the C file, producing
an executable empcnt.exe, and the SQL/MX compiler compiles empcnt.m.
Because the module-tableset-specification-string is specified as
TEST, the module file produced by the SQL/MX compiler is:
/usr/tandem/sqlmx/USERMODULES/CAT.SCH.^EMP_CNT_MODULE^TEST^
To indicate that the executable was built to use the TEST compiled module file, the
executable is named empcnt_test.exe.
If you want to rebuild the application to target a set of production files, you can do so
without changing the source file (empcnt.sql):
1. Use the OSS add_define command to give =DEPT and =EMPLOYEE the table
location to target a different set of files:
add_define =DEPT class=MAP file=\\PROD.\$DATA.HR1.DEPT
add_define =EMPLOYEE class=MAP \
file=\\PROD.\$DATA.HR1.EMPLOYEE
2. Invoke the preprocessor, specifying a module-tableset-specification-
string with the -g option and a different value:
mxsqlc empcnt.sql -c empcnt.c -m empcnt.m \
-g moduleTableSet=PROD
3. The previous step again produces a pure C file, empcnt.c, and a module
definition file named empcnt.m.
The c89 utility compiles and links the C file, producing an executable, and the
SQL/MX compiler compiles empcnt.m. The executable is named
empcnt_prod.exe to denote that it was prepared to use the module files that are
targeted to use the production set of tables.
Because a module-tableset-specification-string was specified, the
module file produced by the SQL/MX compiler is:
/usr/tandem/sqlmx/USERMODULES/CAT.SCH.^EMP_CNT_MODULE^PROD^
Note. These two files (empcnt.c and empcnt.m) overwrite the C and module definition
files that were written the first time the application is built. mxsqlc does not check for the
existence of identically named files before it writes its output files. Although you can
specify different output file names to avoid this situation, you might not care that the
second C and module definition files overwrite the first build’s files because they are easily
reproducible. However, if you want to preserve the output of the preprocessor and avoid
overwriting files, see Targeting Example for C: Using Build Subdirectory
on page 17-17 or
Targeting Example for COBOL: Using a Build Subdirectory
on page 17-20.