SQL.Commit
----------

Saves any changes and ends the current transaction.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [SQL](component_SQL.md) | [2.6](newinversion26.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "SQL.Commit"; Connection ) 

**MBS**( **"SQL.Commit";** /\* Saves any changes and ends the current transaction. \*/  
**$Connection**) /\* The connection reference number gained with [SQL.NewConnection](SQLNewConnection.md). \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Connection | The connection reference number gained with [SQL.NewConnection](SQLNewConnection.md). | $Connection |

### Result

Returns "OK" or error message.

### Description

Saves any changes and ends the current transaction.   
Use Commit method to write transaction changes permanently to a database. It commits the work of all commands that associated with that connection.   
All changes to the database since the last commit are made permanent and cannot be undone. Before a commit, all changes made since the start of the transaction can be rolled back using [SQL.Rollback](SQLRollback.md) method.  
### Examples

Run something in transaction:

 Set Variable \[ $Command ; Value: MBS ("[SQL.NewCommand](SQLNewCommand.md)"; $Connection ; “BEGIN TRANSACTION“ ) \]  
\# run it   
Set Variable \[ $result2 ; Value: MBS ("[SQL.Execute](SQLExecute.md)"; $Command ) \]  
\# and free command   
Set Variable \[ $result4 ; Value: MBS ("[SQL.FreeCommand](SQLFreeCommand.md)"; $Command ) \]  
  
\# create command   
Set Variable \[ $Command ; Value: MBS ("[SQL.NewCommand](SQLNewCommand.md)"; $Connection ; "some other SQL command here" ) \]  
\# run it   
Set Variable \[ $result2 ; Value: MBS ("[SQL.Execute](SQLExecute.md)"; $Command ) \]  
\# and free command   
Set Variable \[ $result4 ; Value: MBS ("[SQL.FreeCommand](SQLFreeCommand.md)"; $Command ) \]  
  
  
\# create command   
Set Variable \[ $Command ; Value: MBS ("[SQL.NewCommand](SQLNewCommand.md)"; $Connection ; "some other SQL command here") \]  
\# run it   
Set Variable \[ $result2 ; Value: MBS ("[SQL.Execute](SQLExecute.md)"; $Command ) \]  
\# and free command   
Set Variable \[ $result4 ; Value: MBS ("[SQL.FreeCommand](SQLFreeCommand.md)"; $Command ) \]  
  
\# commit changed   
Set Variable \[ $result3 ; Value: MBS ("SQL.Commit"; $Connection ) \]  
### See also

- [FM.SQL.InsertRecordsToSQL](FMSQLInsertRecordsToSQL.md)
- [SQL.Execute](SQLExecute.md)
- [SQL.FreeCommand](SQLFreeCommand.md)
- [SQL.InsertOrUpdateRecords](SQLInsertOrUpdateRecords.md)
- [SQL.NewCommand](SQLNewCommand.md)
- [SQL.NewConnection](SQLNewConnection.md)
- [SQL.Rollback](SQLRollback.md)
- [SQL.SetParamAsContainer](SQLSetParamAsContainer.md)
- [SQL.SetParamsWithJSON](SQLSetParamsWithJSON.md)
- [SQL.SetParamValues](SQLSetParamValues.md)

### Example Databases

- [SQL in FileMaker/Insert or Update Tests](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20in%20FileMaker/Insert%20or%20Update%20Tests.shtml#14ScriptAnchor_)
- [SQL to other databases/MySQL example](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/MySQL%20example.shtml#1ScriptAnchor_)
- [SQL to other databases/PostgreSQL Query](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/PostgreSQL%20Query.shtml#3ScriptAnchor_)
- [SQL to other databases/SQL Export](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/SQL%20Export.shtml#1ScriptAnchor_)
- [SQL to other databases/SQLite blob](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/SQLite%20blob.shtml#1ScriptAnchor_)
- [SQL to other databases/SQLite fun](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/SQLite%20fun.shtml#1ScriptAnchor_)
- [Third Party/FileMaker Snippet Storage](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Third%20Party/FileMaker%20Snippet%20Storage.shtml#43CustomFunctionAnchor_)

### Blog Entries

- [Transactions with SQL functions](https://www.mbsplugins.de/archive/2022-04-28/Transactions_with_SQL_function/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 1/2016, Seite 30](https://filemaker-magazin.de/neuigkeit/3870-Appetithappen-FMM_201601)
- [Ausgabe 4/2015, Seite 16](https://filemaker-magazin.de/neuigkeit/3822-Appetithappen-FMM_201504)

This function is free to use.

Created 18th August 2014 , last changed 5th September 2025

  
[SQL.CommandType](SQLCommandType.md) - [SQL.Connect](SQLConnect.md)

[HTML Version](SQLCommit.shtml)