|Used at compile time:||No|
|Behavior at run time:||Process|
See Scope - OpenESQL SQL Compiler Directive Options for more information.
Because NOAUTOCOMMIT is used by default, OpenESQL default behavior explicitly turns off the SQL connection's autocommit attribute regardless of how the connection was created.
For OpenESQL connections, NOAUTOCOMMIT allows your application to control local transactions, with normal COMMIT and ROLLBACK statements; however, for connections not created by OpenESQL such as an external connection created by a Java application server, turning off the connection's autocommit attribute by using NOAUTOCOMMIT could result in error.
When AUTOCOMMIT is specified explicitly, the SQL connection's autocommit attribute is not altered, whether the connection was created by OpenESQL or by some other means. The result for OpenESQL connections is that AUTOCOMMIT commits every SQL statement in your application, operating in "autocommit mode." With external connections, the autocommit attribute is not modified, so your application continues to participate in the transaction managed externally.
The SET AUTOCOMMIT embedded SQL statement overrides the AUTOCOMMIT compiler directive option.
An application can programmatically control the autocommit setting for a connection by executing the EXEC SQL SET AUTOCOMMIT statement.
An application in autocommit mode can start a local database transaction with the EXEC SQL BEGIN TRANSACTION statement. The transaction ends when the next COMMIT or ROLLBACK statement is executed.
When a transaction ends, if the connection's autocommit attribute is on, the connection reverts to autocommit mode; otherwise a new local database transaction is started automatically.