Managing Transactions

With Embedded SQL, you can use the full transaction control facilities of SQL Server.

The COMMIT statement marks the end of a user-defined transaction that was initiated by a BEGIN TRANSACTION statement. The COMMIT statement makes changes to the transaction's database permanent and visible to other users. It also removes all locks from the affected data so that other users can access the data.

As with other SQL Server applications, statements that are not bound by BEGIN TRANSACTION and COMMIT are automatically committed when the statement executes without an error.

The ROLLBACK statement reverses the effects of a user-specified transaction to the beginning of the OPEN TRANSACTION or to the last save point (marked by a Transact-SQL SAVE TRANSACTION statement) inside the open transaction. After a transaction is committed, it cannot be rolled back.

Note that by default, a COMMIT or ROLLBACK statement does not close cursors and applies only to the current connection if multiple connections are active. You can use the SET CURSOR_CLOSE_ON_COMMIT statement to automatically close all cursors on a connection when a COMMIT TRANSACTION or a ROLLBACK TRANSACTION statement is issued.