Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.0 (Français) » SQL Anywhere Server - Programming » Using SQL in applications » Controlling transactions in applications » Setting autocommit or manual commit mode

 

Controlling 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. See Autocommit implementation details.

 ♦  To control autocommit mode (ADO.NET)
  • By default, the ADO.NET provider operates in autocommit mode. To use explicit transactions, use the SAConnection.BeginTransaction method. See Transaction processing.

 ♦  To 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.

 ♦  To 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.

 ♦  To 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 );
 ♦  To 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';
 ♦  To 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';
 ♦  To control autocommit mode (PHP)
  • By default, PHP operates in autocommit mode. To turn off autocommit, use the sqlanywhere_set_option function:

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

See sasql_set_option.

 ♦  To 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.

See Setting autocommit or manual commit mode.