SQL/MX 3.2 Programming Manual for C and COBOL (H06.25+, J06.14+)
Program and Module Management
HP NonStop SQL/MX Release 3.2 Programming Manual for C and COBOL—663854-002
17-22
Versioning
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.
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-17), 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.
C










