ASA Programming Guide
Using SQL in Applications
Controlling transactions in applications
Setting autocommit or manual commit mode
The previous section, Controlling autocommit behavior, describes how autocommit behavior can be controlled from each of the Adaptive Server Anywhere programming interfaces. Autocommit mode has slightly different behavior depending on the interface you are using and how you control the autocommit behavior.
Autocommit mode can be implemented in one of two ways:
Client-side autocommit When an application uses autocommit, the client-library sends a COMMIT statement after each SQL statement executed.
Adaptive Server Anywhere uses client-side autocommit for ODBC and OLE DB applications.
Server-side autocommit When an application uses autocommit, the database server issues a commit after each SQL statement. This behavior is controlled, implicitly in the case of JDBC, by the CHAINED database option.
Adaptive Server Anywhere uses server-side autocommit for embedded SQL, JDBC, and Open Client applications.
There is a difference between client-side and server-side autocommit in the case of compound statements such as stored procedures or triggers. From the client side, a stored procedure is a single statement, and so autocommit sends a single commit statement after the whole procedure is executed. From the database server perspective, the stored procedure may be composed of many SQL statements, and so server-side autocommit issues a COMMIT after each SQL statement within the procedure.
Do not mix client-side and server-side implementationsDo not combine use of the CHAINED option with autocommit in your ODBC or OLE DB application. |