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-19
Versioning
-g moduleTableSet=$TableSet
nmcobol -o ./$TableSet/empcnt.exe \
-Wcobol=”CONSULT /usr/tandem/sqlmx/lib/sqlcli.o” \
-lzclisrl ./$TableSet/empcnt.cbl
/G/system/system/mxcmp ./$TableSet/empcnt.m
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 COBOL and module definition files are written into that
subdirectory by the preprocessor and read from that subdirectory by the COBOL
compiler and mxcmp, respectively. (See references to $TableSet on the command
lines for mxsqlco, nmcobol, and mxcmp.)
The script also uses the environment variable TableSet on the nmcobol command
line so that its output object file (empcnt.exe) is written into the subdirectory.
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 into 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^
Versioning
By using the version attribute for module management, you can create and use
multiple versions of an application from a single embedded SQL source file without
changing the MODULE directive or the catalog or schema. In the embedded SQL
source file, you would change the source code according to the new version but keep
the same MODULE directive. Versioning and targeting differ in that versioning typically
requires you to make minor changes to the source code of the application.
The version attribute is necessary if you want two or more versions of the application
(and its module files) to coexist on the same NonStop system. Without the version
attribute, each build of the application writes an identically named module in the
/usr/tandem/sqlmx/USERMODULES directory, unless you change the MODULE
directive in the source code or unless you instruct the SQL/MX compiler to generate
locally placed modules. The version attribute prevents a subsequently built application
from overwriting the module file of the previously built application.