SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
14-1
14 Transaction Management
A transaction, which is a set of database changes that must be completed as a group, 
is the basic recoverable unit in case of a failure or transaction interruption. 
The typical order of events is:
1. Transaction is started.
2. Database changes are made.
3. Transaction is committed if the database changes are made successfully. 
If the transaction cannot successfully make the changes or if you do not want to 
complete the transaction, you can abort the transaction and roll the database back to 
its original state.
This section describes:
•
Transaction Control Statements on page 14-1
•
Steps for Ensuring Data Consistency on page 14-1
For more information on transaction management, see the SQL/MX Reference 
Manual.
Transaction Control Statements
Control the transactions in an C/C++/COBOL program by specifying these SQL/MX 
statements in an embedded SQL source file:
•
BEGIN WORK statement
•
COMMIT WORK statement
•
ROLLBACK WORK statement
•
SET TRANSACTION statement
For the syntax of these statements, see the SQL/MX Reference Manual. To use these 
transaction control statements in your C/C++/COBOL program, see Steps for Ensuring 
Data Consistency on page 14-1
Steps for Ensuring Data Consistency
Figure 14-1 shows the steps presented within the complete C program. These steps 
are executed in the sample program Example A-2 on page A-4.
Figure 14-1. Coding Transaction Control Statements in a C Program
...
char SQLSTATE_OK[6] = "00000"; 
...
EXEC SQL BEGIN DECLARE SECTION;
char SQLSTATE[6]; 
...
EXEC SQL END DECLARE SECTION; 
...
C
1










