6. Working with Transactions and Handling Errors : Transactions : Set Autocommit On--Commit Individual Statement
 
Share this page                  
Set Autocommit On--Commit Individual Statement
A transaction begins with the first statement after connection to the database or the first statement following a commit or rollback (including rollbacks performed by the DBMS). Subsequent statements are part of the transaction until a commit or rollback is executed. By default, an explicit commit or rollback must be issued to close a transaction.
To direct the DBMS to commit each database statement individually, use the SET AUTOCOMMIT ON statement. This statement cannot be issued in an open transaction. When autocommit is set on, a commit occurs automatically after every statement, except PREPARE and DESCRIBE. If autocommit is on and a cursor is opened, the DBMS does not issue a commit until the CLOSE cursor statement is executed, because cursors are logically a single statement. A ROLLBACK statement can be issued when a cursor is open.
To restore the default behavior (and enable multi-statement transactions), issue the SET AUTOCOMMIT OFF statement.