---
url: >-
  /flow/guide/scripting-reference/functions/database/execsqlstatementandcommit.md
---

# ExecSQLStatementAndCommit

## Declaration

`function ExecSQLStatementAndCommit(const aSQL: string; aDBIndex : integer): boolean;`

### Example

```pascal
procedure OnMapEvent(var Value:Variant);
begin
  Value := ExecSQLStatementAndCommit('update dr_accs set name='cam' where accno=1',0);
end;
```

## Description

Executes aSQL query against the database and returns True or False regarding the success of the query. This is commonly used with SQL statements that do not return a dataset eg Insert or Update

The SQL query is executed against a DB Connection on the Destination of the map. aDBIndex indicates which of the DB Connections is used based on its zero based index.

::: tip
The SQL query will use its own SQL Transaction and be committed immediately on success execution. This means that should the action fail at a later point this data will remain in the destination database.
:::
