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 COBOL544617-003
15-64
Building SQL/MX Guardian Applications in the OSS
Environment
ctoedit progcpp,progsrc
== Call the NMCPLUS compiler to generate the object file.
nmcplus/in progsrc,out progout/progo;version2
== Call the nld linker to generate an executable file.
nld $system.system.crtlmain progo -o progexe -obey &
$system.system.libcobey &
-lzclisrl -lzcplsrl -lztlhsrl -noverbose
== Execute the executable.
run progexe
Building SQL/MX Guardian Applications in the OSS
Environment
You can use the c89 -Wsystype=guardian option to build an SQL/MX Guardian
application in the OSS environment. Follow these steps:
1. Create an embedded SQL/MX C/C++ source file (for example, prog.ec) in the
OSS environment.
2. Compile the C/C++ source file by using the -Wsystype=guardian option of the
OSS compiler utility:
c89 -Wsqlmx -Wmxcmp -Wsystype=guardian prog.ec \
-o prog.exe
3. Copy the executable file, prog.exe, from an OSS directory to a Guardian volume
and subvolume:
cp prog.exe /G/myvol/mysubvol/progexe
4. In the Guardian environment, assign file code 800 (for TNS/E native applications)
or file code 700 (for TNS/R native applications) to the executable file:
TACL> fup alter progexe, code 800
TACL> fup alter progexe, code 700
5. Run the executable in the Guardian environment:
TACL> run progexe
Running an SQL/MX Application
This subsection describes how C or C++ application code is correctly linked to the
compiled SQL/MX user module. Topics include:
Running the SQL/MX Program File on page 15-65
Understanding and Avoiding Some Common Run-Time Errors on page 15-65
Debugging a Program on page 15-67
Displaying Query Execution Plans on page 15-67
As stated in Running the SQL/MX C/C++ Preprocessor on page 15-8, when the
preprocessor reads an embedded SQL source file and writes the C/C++ annotated
source file, it replaces the SQL statements with C code to call the SQL CLI to execute