---
url: >-
  /statelake/scripting-reference/functions-and-procedures/database-functions/execsqlstatementandcommit.md
---

# ExecSQLStatementAndCommit

**ExecSQLStatementAndCommit** executes an **aSQL** query against the database, and depending on the success of the query, returns either a **True** or False.

The **SQL** query is executed against a **DB Connection** on the **Destination** of the **Map**.

The **SQL** query will use its own **SQL Transaction** and will be committed immediately on a successful execution. This means that should the **Action** fail at a later point, this data will remain in the **Destination** database.

This is commonly used with **SQL** statements that do not return a dataset eg Insert or Update,

**aDBIndex** indicates which of the **DB Connections** is used based on its zero based index.

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;
```
