Represents a transaction in a database.
A transaction groups statements that should succeed or fail as a whole in order to maintain the database in a consitent state. Once all statements
have been executed and the transaction can be committed the application should call SetSuccessful
. Depending on IsSuccessful
TSqlDatabase.EndTransaction
either commits or rolls back the transactions. The following pattern should be used:
1
2
3
4
5
6
7
8
| Transaction := Database.StartTransaction();
try
ExecuteStatements();
Transaction.SetSuccessful();
finally
Database.EndTransaction(Transaction);
end;
|