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-20
Versioning
Versioning Guidelines
You specify versioning by using the C/C++ or COBOL preprocessor option -g and 
setting the moduleVersion attribute to a Module-Version-Specification-
String (MVSS). This MVSS is embedded in the module name, which is used to name 
the module file. As with the targeting feature, you need to take steps to prevent the 
second version of the executable file from overwriting the first. However, unlike the 
targeting feature, you can use versioning without using compile-time name resolution, 
so you need not set up class MAP DEFINEs before running the application.
In addition to allowing multiple versions of an application to exist, when a unique MVSS 
is specified each time a module file is precompiled, you can also perform live 
upgrades. Because you can distinguish versions by using the MVSS attribute, 
processes running from an earlier program file can use SQL plans from an earlier 
version of a module file (for example, version 1), and a new program file can use SQL 
plans from a newer version of a module file (for example, version 2). 
Versioning Example: C Set Up 
In this example, an environment variable is set ($ThisVersion), and a build script is 
invoked. The script contains this line to run the preprocessor:
mxsqlc empcnt.sql -c $ThisVersion/empcnt.c \
 -m $ThisVersion/empcnt.m \
 -g moduleVersion=$ThisVersion
Similar to the example that showed a build subdirectory used for targeting (see 
Targeting Example for C: Using Build Subdirectory on page 17-15), the parts of the 
build script that invoke c89 read empcnt.c from and write empcnt.o to the 
$ThisVersion subdirectory. Similarly, the line invoking nld reads 
$ThisVersion/empcnt.o and writes $ThisVersion/empcnt.exe to prevent 
each version’s intermediate and executable files from overwriting each other. This 
scenario also applies to the next COBOL example.
If the environmental variable is set both for V1 and for V2, after the build script is run 
for each version, an executable exists in subdirectories V1 and V2. These two module 
files will coexist:
/usr/tandem/sqlmx/USERMODULES/CAT.SCH.^EMP_CNT_MODULE^^V1
/usr/tandem/sqlmx/USERMODULES/CAT.SCH.^EMP_CNT_MODULE^^V2
Versioning Example: COBOL Set Up
In this example, an environment variable ThisVersion is set, and a build script is 
invoked:
mxsqlco empcnt.ecbl -c $ThisVersion/empcnt.cbl \
 -m $ThisVersion/empcnt.m \
 -g moduleVersion=$ThisVersion
C
COBOL










