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

Transaction Management
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
14-4
Setting Attributes for Transactions
Example
The attributes include access mode and isolation level, which affect the degree of
concurrent data access:
...
EXEC SQL SET TRANSACTION
READ ONLY,
ISOLATION LEVEL READ UNCOMMITTED,
DIAGNOSTICS SIZE 10;
...
The last attribute shown in this example, the diagnostics size, is an estimate of the
number of exception conditions you might expect as a result of executing an SQL
statement within the transaction. Specifically, the diagnostics size is the maximum
number of condition items for a statement item.
To set attributes for transactions in an C/C++/COBOL program, see:
Autocommit Setting on page 14-4
Isolation Level Setting on page 14-5
Default Transaction Attributes on page 14-6
Autocommit Setting
The autocommit setting specifies whether an implicit transaction commits automatically
at the end of statement execution or rolls back automatically if an error occurs. When
autocommit is enabled (that is, turned on), each implicit transaction commits
automatically at the end of statement execution.
The BEGIN WORK statement turns off the autocommit setting inside an explicit, user-
defined transaction. Even if you turn on the autocommit setting before an explicit
transaction starts, you must code a COMMIT WORK statement to commit the
transaction. By default, autocommit is off in C/C++/COBOL programs. To turn on
autocommit, issue a SET TRANSACTION statement in your application. For more
information on autocommit, see the SQL/MX Reference Manual.
Use SET TRANSACTION at the beginning of your C program to commit changes
automatically at the end of each SQL statement:
...
EXEC SQL SET TRANSACTION AUTOCOMMIT ON;
...
Use a separate SET TRANSACTION statement to set AUTOCOMMIT ON. You cannot
specify this option in combination with any other option in the SET TRANSACTION
statement.
See the SET TRANSACTION statement in the SQL/MX Reference Manual.
C