Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
12.2
12.3
12.4
12.5
13.0
13.1
13.2
13.3
13.4
13.5
Statistic
FMM
Blog
Creates or updates records in FileMaker database for current recordset.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
SQL | 7.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
Command | The command reference number gained with SQL.NewCommand. | $Command | |
InsertFileName | The file name of where the insert table is inside. Can be empty to look for the table in all files. | Get(FileName) | |
InsertTableName | The name of the table to insert record into. | "Assets" | |
FieldNames | A list of field names for the insert. Empty entries in the list are ignored. |
"Model" | |
PrimaryKeyDB1 | The name of the primary key in the record set. Must be one of the columns in the record from SQL. If empty, we use primaryKeyFM1 here. |
"RowID" | |
PrimaryKeyFM1 | The name of the primary key for the update statements. Must be one of the columns in the FileMaker table. If empty, we use primaryKeyDB1 here. |
"RowID" | |
SecondaryKeyDB2 | Available in MBS FileMaker Plugin 8.1 or newer. The name of the secondary key in the record set. Must be one of the columns in the record from SQL. If empty, we use primaryKeyFM2 here. |
"ClientID" | Optional |
SecondaryKeyFM2 | Available in MBS FileMaker Plugin 8.1 or newer. The name of the secondary key for the update statements. Must be one of the columns in the FileMaker table. If empty, we use primaryKeyDB2 here. |
"ClientID" | Optional |
TertariyKeyDB3 | Available in MBS FileMaker Plugin 8.1 or newer. The name of the tertary key in the record set. Must be one of the columns in the record from SQL. If empty, we use primaryKeyFM3 here. |
"CompanyID" | Optional |
TertariyKeyFM3 | Available in MBS FileMaker Plugin 8.1 or newer. The name of the tertary key for the update statements. Must be one of the columns in the FileMaker table. If empty, we use primaryKeyDB3 here. |
"CompanyID" | Optional |
Returns list or error.
Insert or update records:
# get connection before.
# Create select and run it
Set Variable [ $Command ; Value: MBS("SQL.NewCommand"; $Connection; "SELECT RowID, FirstName, LastName, TotalSales, NumberOfOrders FROM Test") ]
# Run it
Set Variable [ $result ; Value: MBS("SQL.Execute"; $Command) ]
If [ $result ≠ "OK" ]
Show Custom Dialog [ "Error: " & $result ]
Else
Set Variable [ $result ; Value: MBS("SQL.InsertOrUpdateRecords"; $Command; Get(FileName); "SQLite fun"; "PKey¶FirstName¶LastName¶TotalSales¶NumberOfOrders"; "RowID"; "PKey") ]
Show Custom Dialog [ "Records imported." & ¶ & ¶ & $result ]
End If
# Cleanup
Set Variable [ $result2 ; Value: MBS("SQL.FreeCommand"; $Command) ]
Set Variable [ $result2 ; Value: MBS("SQL.Commit"; $Connection) ]
Set Variable [ $result2 ; Value: MBS("SQL.FreeConnection"; $Connection) ]
This function checks for a license.
Created 21st June 2017, last changed 15th October 2021