How to control autocommit behavior

The way to control the commit behavior of your application depends on the programming interface you are using. The implementation of autocommit may be client-side or server-side, depending on the interface.

Control autocommit mode (ADO.NET)

By default, the ADO.NET provider operates in autocommit mode. To use explicit transactions, use the SAConnection.BeginTransaction method.

Control autocommit mode (OLE DB)

By default, the OLE DB provider operates in autocommit mode. To use explicit transactions, use the ITransactionLocal::StartTransaction, ITransaction::Commit, and ITransaction::Abort methods.

Control autocommit mode (ODBC)

By default, ODBC operates in autocommit mode. The way you turn off autocommit depends on whether you are using ODBC directly, or using an application development tool. If you are programming directly to the ODBC interface, set the SQL_ATTR_AUTOCOMMIT connection attribute.

Control autocommit mode (JDBC)

By default, JDBC operates in autocommit mode. To turn off autocommit, use the setAutoCommit method of the connection object:

conn.setAutoCommit( false );

Control autocommit mode (embedded SQL)

By default, embedded SQL applications operate in manual commit mode. To turn on autocommit, set the chained database option (a server-side option) to Off using a statement such as the following:

SET OPTION chained='Off';

Control autocommit mode (Open Client)

By default, a connection made through Open Client operates in autocommit mode. You can change this behavior by setting the chained database option (a server-side option) to On in your application using a statement such as the following:

SET OPTION chained='On';

Control autocommit mode (PHP)

By default, PHP operates in autocommit mode. To turn off autocommit, use the sasql_set_option function:

$result = sasql_set_option( $conn, "auto_commit", "Off" );

Control autocommit mode (on the server)

By default, the database server operates in manual commit mode. To turn on automatic commits, set the chained database option (a server-side option) to Off using a statement such as the following:

SET OPTION chained='Off';

If you are using an interface that controls commits on the client side, setting the chained database option (a server-side option) can impact performance and/or behavior of your application. Setting the server's chained mode is not recommended.