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-51
Building and Deploying a C Application With
Embedded Module Definitions and Module Definition
EXEC SQL DECLARE CURSOR m FOR SELECT * FROM =midcaps;
int main() { ...
}
2. Run the SQL/MX C/C++ preprocessor:
mxsqlc sqlapp.sql -c sqlapp.cpp
This command creates an annotated source file (sqlapp.cpp) that contains the
SQL/MX CLI call translations of the embedded SQL statements and an extra
C/C++ source construct that represents its module definition.
Because no module specification strings were specified at the command line,
mxsqlc generates code using the module name ‘cat.sch.sqlappmod.’ The
SQL/MX object naming rules for default catalog and schema apply to an
unqualified module directive, in addition to other unqualified names of tables,
views, and other SQL objects.
3. Run the C/C++ compiler on sqlapp.cpp:
c89 -Wversion2 -I/usr/tandem/sqlmx/include -c sqlapp.cpp
4. Run the native linker on sqlapp.o and sqlutil.o to create the sqlapp.exe
executable file.
•
For TNS/E native applications, use the eld utility:
eld -verbose /usr/lib/ccplmain.o sqlapp.o sqlutil.o
-o sqlapp.exe -lzcppcdll -lzcpp2dll -lztlh7dll -lzcredll \
-lzcrtldll -lzosskdll -lzi18ndll -lzicnvdll -lzclidll
•
For TNS/R native applications, use the nld utility:
nld -elf -set systype oss -set highpin off\
-set highrequestor on -set inspect on \
-obey /usr/lib/libc.obey -set saveabend on \
/usr/lib/crtlmain.o sqlapp.o sqlutil.o \
-lzcplsrl -lzcrtlsrl -lzcresrl -lzcplosrl -lztlhgsrl \
-lztlhosrl -Bdynamic -lzclisrl -o sqlapp.exe
5. Run the SQL/MX compiler after setting up class MAP DEFINEs:
add_define =midcaps class=map \
file=\\pecan.\$data07.holding.midcaps
mxCompileUserModule -v -d AUTOMATIC_RECOMPILATION=ON \
-d RECOMPILATION_WARNINGS=ON -d SIMILARITY_CHECK=ON \
sqlapp.exe
This command compiles the application’s module ‘cat.sch.sqlappmod.’
Assuming that the sqlutil.o’s compiled module is still current, you can now run
sqlapp.exe.










