SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)

COBOL Program Compilation
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
16-43
Running an SQL/MX Application
2. Compile the COBOL source file by using the -Wsystype=guardian option of the
OSS compiler utility:
nmcobol -Wsqlmx -Wmxcmp -Wsystype=guardian prog.ecob \
-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 700 (for TNS/R native applications)
to the executable file:
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 COBOL application code is correctly linked to the
compiled SQL/MX user module. Topics include:
Running the SQL/MX Program File on page 16-44
Understanding and Avoiding Common Run-Time Errors on page 16-44
Displaying Query Execution Plans on page 16-45
As stated in Running the SQL/MX COBOL Preprocessor on page 16-9, when the
preprocessor reads an embedded SQL source file and writes the COBOL annotated
source file, it replaces the SQL statements with COBOL 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 COBOL 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.