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 COBOL523627-004
17-16
Targeting Example for COBOL: Using
ModuleTableSet (MTSS)
The shell script makes a subdirectory that is named from the environment variable
$TableSet (which was set to TEST in the previous example). The script is written so
that the intermediate C and module definition files are written into that subdirectory by
the preprocessor and read from that subdirectory by the C compiler and mxcmp,
respectively. (See references to $TableSet on the mxsqlc, c89, and mxcmp
command lines.)
The script also uses the environment variable TableSet on the c89 command line so
that its output object file, empcnt.o, is written to the subdirectory. Similarly, the nld
command line uses the same environmental variable to read empcnt.o from that
subdirectory and write empcnt.exe to it as well.
When you need to create another copy of the application to target a different set of
tables, export a different value for TableSet and set different values to the two
DEFINEs. For example:
export TableSet=PROD
add_define =DEPT class=MAP file=\\PROD.\$DATA.HR1.DEPT
add_define =EMPLOYEE class=MAP
file=\\PROD.\$DATA.HR1.EMPLOYEE
Then rerun the previous empcnt.sh shell script. The second set of intermediate files
and the .exe file are written to a different subdirectory. As in the first example, two
distinct module files have been created by the time the two builds complete:
/usr/tandem/sqlmx/USERMODULES/CAT.SCH.^EMP_CNT_MODULE^TEST^
/usr/tandem/sqlmx/USERMODULES/CAT.SCH.^EMP_CNT_MODULE^PROD^
The two executables can coexist, each in their own subdirectory:
TEST/empcnt.exe
PROD/empcnt.exe
Targeting Example for COBOL: Using ModuleTableSet (MTSS)
In this example, a COBOL application, which counts employees in various
departments, is prepared twice to make use of two different sets of tables. One set of
tables is for a test environment, and the other set of tables is for a production
environment. In a source file (empcnt.ecbl), the application’s SQL statements are
coded with class MAP DEFINEs:
EXEC SQL DECLARE COUNT_EMP_BY_DEPT CURSOR FOR
SELECT D.DEPT_NUM, COUNT(E.EMP_NUM)
FROM =DEPT AS D, =EMPLOYEE AS E
WHERE D.DEPT_NUM = E.EMP_DEPTNUM GROUP BY D.DEPT_NUM END-EXEC.
The application has a MODULE directive:
EXEC SQL MODULE CAT.SCH.EMP_CNT_MODULE NAMES ARE
ISO88591 END-EXEC.
To build the application, targeting a set of tables on a test system:
COBOL