SQL.SetAutoCommit
-----------------

Enables or disables autocommit for the current connection, that is, automatic commit of every SQL command.

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

MBS( "SQL.SetAutoCommit"; Connection; AutoCommit ) 

**MBS**( **"SQL.SetAutoCommit";** /\* Enables or disables autocommit for the current connection, that is, automatic commit of every SQL command. \*/  
**$Connection**; /\* The connection reference number gained with [SQL.NewConnection](SQLNewConnection.md). \*/   
**$AutoCommit**) /\* Whether to turn auto commit on or off. Can be "On" or "Off".e.g. "On" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| Connection | The connection reference number gained with [SQL.NewConnection](SQLNewConnection.md). | $Connection |
| AutoCommit | Whether to turn auto commit on or off. Can be "On" or "Off". | "On" |

### Result

Returns "OK" or error message.

### Description

Enables or disables autocommit for the current connection, that is, automatic commit of every SQL command.  
If autocommit is on, the database is committed automatically after each SQL command. Otherwise, transaction is committed only after Commit calling.   
### Examples

Turn auto commit off:

 MBS ( "SQL.SetAutoCommit"; $Connection ; "off" )  
### See also

- [SQL.GetAutoCommit](SQLGetAutoCommit.md)
- [SQL.NewConnection](SQLNewConnection.md)

### Example Databases

- [SQL to other databases/PostgreSQL Query](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/SQL%20to%20other%20databases/PostgreSQL%20Query.shtml#3ScriptAnchor_)

### 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)

This function is free to use.

Created 18th August 2014 , last changed 25th October 2018

  
[SQL.ServerVersionString](SQLServerVersionString.md) - [SQL.SetClient](SQLSetClient.md)

[HTML Version](SQLSetAutoCommit.shtml)