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

Introduction
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
1-11
Compiling and Building an Application
If all changes cannot be made or you do not want to complete a transaction for some
other reason, you can abort the transaction and return the database to its state before
the transaction started.
To ensure that a sequence of statements either executes successfully or not at all, you
can define one transaction consisting of these statements by enclosing the sequence
within the BEGIN WORK and COMMIT WORK statements. You can abort a
transaction with the ROLLBACK WORK statement.
Alternatively, you can commit changes automatically at the end of each SQL statement
by using SET TRANSACTION AUTOCOMMIT ON at the beginning of your program.
The default for embedded SQL is AUTOCOMMIT OFF.
If you exit a program without using either of these methods, any uncommitted changes
are automatically rolled back.
See also Section 14, Transaction Management.
Compiling and Building an Application
NonStop SQL/MX provides two methods of creating a module:
Processing With Embedded Module Definitions on page 1-11
Processing With Module Definition Files on page 1-12
The first method is the default method of processing programs in SQL/MX Release 2.x
and later product versions. The second method is the only method of processing
programs in SQL/MX Release 1.8. Although identical module definitions and identical
modules are produced with either technique, HP recommends that you produce
modules by using embedded module definitions.
By default, modules are created in the /usr/tandem/sqlmx/USERMODULES
directory. Command line options with mxCompileUserModule and mxcmp and the
MXCMP_PLACES_LOCAL_MODULE default setting provide the ability to place
modules in local directories.
Processing With Embedded Module Definitions
This method, which is the default method in SQL/MX Release 2.x and later product
versions, does not use module definition files (.m files) for SQL/MX-specific information
to be SQL compiled. The preprocessor reads a 3GL source file that contains C/C++ or
COBOL and SQL statements and generates one file: a single, self-contained source
file that contains embedded module definitions. The annotated source file contains the
source statements with the SQL statements converted to comments. To produce the
module, compile the source file with the host language compiler and use the
mxCompileUserModule command-line tool to SQL compile the embedded module
definition.
For more information, see: