SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
C/C++ Program Compilation
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
15-58
Running an SQL/MX Application
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-58
•
Understanding and Avoiding Some Common Run-Time Errors on page 15-59
•
Debugging a Program on page 15-60
•
Displaying Query Execution Plans on page 15-60
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 
the SQL statement, along with code to handle parameter passing and error processing. 
At run time, the calls to the CLI pass in a descriptor of the statement, which gives the 
statement name, the module name, and a module timestamp.
The CLI begins processing each call by checking that it has the associated module in 
memory. If not, it uses the module name to find the correct module file in the 
application’s base directory. If a co-located module is not found there, it looks for the 
module file in the /usr/tandem/sqlmx/USERMODULES directory. Before it reads in 
the compiled SQL plans from a module file, the CLI also checks that the module 
timestamp encoded in the module file matches the module timestamp passed in from 
the C/C++ application. 
If the application consists of more than one separately compiled module, when the first 
statement from the module is executed, the sequence of reading the module file and 
checking its module timestamp is performed and repeated for each module associated 
with the application.
Security of the /usr/tandem/sqlmx/USERMODULES directory is very important. You 
should restrict access so that users cannot alter the query plans in the modules or 
remove modules. For information on securing modules, see the SQL/MX Installation 
and Management Guide.
Running the SQL/MX Program File
An SQL/MX program can run in the OSS or in the Guardian environment. You can use 
the GTACL command to start a Guardian program from OSS. You can use the osh 
command to start an OSS program from a Guardian TACL session. 
•
From the OSS environment, enter the program file name at the OSS shell prompt. 
You can also use the OSS run command to run the program file by using specific 
Guardian attributes (for example, a CPU or priority for the process). 
•
From the Guardian environment, use the TACL osh command to run the program. 
For more information, see Building SQL/MX C/C++ Applications to Run in the 
Guardian Environment on page 15-53.










