Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
CodeDelphiRAD Studio

Discover How To Easily Manage Database Transactions In Delphi On Windows

To this end, the sample makes use of the following properties and methods of IFDPhysTransaction:

  • The Isolation property, which is used for setting up the transaction isolation level for the transactions that FireDAC manages.
  • The StartTransaction method, which is used to start a new database transaction.
  • The Commit method, which is used to permanently store modifications made in the current transaction to the database.
  • The Rollback method, which is used to cancel all modifications made in the current transaction to the database.

How to Use the Sample

  1. Navigate to the location given above and open IFDPhys_Transactions.dproj.
  2. Press F9 or choose Run > Run.

Files

File in DelphiContains
IFDPhys_Transactions.dproj
IFDPhys_Transactions.dpr
The project itself.
fTransactions.pas
fTransactions.fmx
The main form.

Implementation

When you run the application, clik the Use Connection Definition combo box and select an option in order to define a connection. When the connection is defined, the sample uses the CreateCommand method of IFDPhysConnection to create a command interface. Then, the sample implements the following database transaction features in run time:Set up the transaction isolation levelThe sample sets the Isolation property of IFDPhysTransaction to xiReadCommitted to allow the reading of committed (permanent) changes made to the database by other simultaneous transactions. This is the default value of the Isolation property.Start a transactionThe sample uses the StartTransaction method to start a new database transaction. During the transaction, the sample uses the Prepare method of IFDPhysCommand to execute a DELETE command. The SQL command is the following: 'delete from {id FDQA_TransTable}'.Commit the transactionThe sample uses the Commit method to permanently store modifications made in the current transaction to the database.Rollback the transactionThe sample uses the Rollback method to cancel all the modifications made in the current transaction.Note: The sample use this method if an exception is raised.

Please follow the link below for more information about this sample:

http://docwiki.embarcadero.com/CodeExamples/Sydney/en/FireDAC.IFDPhysConnection.Transactions_Sample

Head over and check out the full source code for the FireDAC Transactions Windows app sample for Delphi.

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES