Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Learn How To Easily Manage Database Transactions With This Delphi Sample App

This sample demostrates how to use the following properties and methods:

Location

You can find the Transactions sample project at:

How to Use the Sample

  1. Navigate to the location given above and open Transactions.dproj.
  2. Press F9 or choose Run > Run.
  3. Click on the Use Connection Definition combo box and select an option.

Files

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

Implementation

The sample implements the following database transaction features:

Setting up Transaction Isolation Level

The sample sets the Isolation property 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. It is set by typing the following code:

[crayon-672a76702deba258633132/]

Controlling Auto Commit Mode

The sample turns off the AutoCommit mode by typing:

[crayon-672a76702dec9695970089/]

Starting transaction

The sample starts a new DBMS transaction by typing:

[crayon-672a76702decc926303535/]

Committing Transaction

To permanently store modifications made in the current transaction to the database, call the Commit method.

[crayon-672a76702dece158843808/]

Rollbacking Transaction

The sample uses the Rollback method to cancel all the current transaction modifications when an exception is raised.

[crayon-672a76702decf775888147/]

Please follow the next link for more information:

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

Exit mobile version