---
url: >-
  /statelake/scripting-reference/classes/data-definition-class-tflodatasource/tflodatasource.committran.md
---

# TFloDataSource.CommitTran

This commits a new database transaction that you started with **StartTransaction** against the **Data Definition**. Any transactions you start with **StartTransaction** will need to be finalised by you with either **CommitTran** or **RollbackTran**.

Database transactions are handled automatically so you do not normally need to use this function unless you want specific control over database transactions.

**Declaration**: Function CommitTran : boolean

This example shows the relationship between **CommitTran** and **RollbackTran**.

```pascal
procedure OnMapEvent(var Value:Variant);
begin
 //Check whether the transaction has started
 if Not Source.CommitTran then
 begin
 //If it fails to commit then you need to rollback
    LogError('Unable to commit transaction');
    Source.RollbackTran;
 end;
end;
```

Please also refer to [TFloDataSource.StartTransaction](/statelake/scripting-reference/classes/data-definition-class-tflodatasource/tflodatasource.starttransaction) and [RollbackTran](/statelake/scripting-reference/classes/data-definition-class-tflodatasource/tflodatasource.rollbacktran).
