---
url: /flow/guide/scripting-reference/classes/data-definition/committran.md
---

# CommitTran

## Declaration

`Function CommitTran : boolean`

### Example

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

## Description

This commits a new database transaction that you started with [StartTransaction](/flow/guide/scripting-reference/classes/data-definition/starttransaction) against the data definition. Database transactions are handled automatically so you do not normally need to use this function unless you want specific control over database transactions.

Any transactions you start with [StartTransaction](/flow/guide/scripting-reference/classes/data-definition/starttransaction) will need to be finalised by you with either CommitTran or [RollbackTran](/flow/guide/scripting-reference/classes/data-definition/rollbacktran)
