SQL/MX Programming Manual for C and COBOL (H06.10+, J06.03+)
C/C++ Program Compilation
HP NonStop SQL/MX Programming Manual for C and COBOL—544617-003
15-52
Quick Builds and mxcmp Defaults in a One-File
Application Deployment
Quick Builds and mxcmp Defaults in a One-File Application
Deployment
Suppose that you are actively developing, testing, and debugging a new SQL/MX
Release 2.x application that you have organized into three separate static SQL C/C++
source files. You can minimize unnecessary SQL recompilations during active
development and still retain the simplicity of building and deploying self-contained
application files by using the named module option of the SQL/MX compiler.
The next example uses mxcmp command-line defaults to module compile an
application executable to work with one set of tables on the development system and
later module compile the same application executable to work with a different set of
tables on the production system.
In addition, this example shows that references to module names are always resolved
early at preprocessing time. It also shows that the resolution of references to other
SQL objects (tables, views, and so on) can be deferred to as late as module
compilation time.
1. Create or edit static SQL C/C++ source files (for example, s1.sql, s2.sql,
s3.sql) as needed:
// s1.sql
EXEC SQL MODULE s1m;
int sow(int a) { ...
EXEC SQL INSERT INTO seeds VALUES(?, ?, ?);
...
}
// s2.sql
EXEC SQL MODULE s2m;
int grow(int j) { ... EXEC SQL UPDATE trees SET h=h+? WHERE
id=?;
...
}
// s3.sql
EXEC SQL MODULE s3m;
int reap(int z) { ...
EXEC SQL DELETE crops WHERE id=?;
...
}
Notice that references to the SQL tables seeds, trees, and crops do not specify
their catalog and schema so that the full resolution of these SQL object references
can be deferred to as late as the module compilation step.
2. Run the SQL/MX C/C++ preprocessor to generate code that references modules
named cat.sch.s1m, cat.sch.s2m, and cat.sch.s3m:
cd /usr/meas
mxsqlc s1.sql -g moduleSchema=cat.sch
mxsqlc s2.sql -g moduleSchema=cat.sch
mxsqlc s3.sql -g moduleSchema=cat.sch










