Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
FM.SQL.InsertRecords
Inserts records in FileMaker database from records in memory.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
FM FMSQL | 6.4 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "FM.SQL.InsertRecords"; SQLref; InsertFileName; InsertTableName; FieldNames { ; StartRow; EndRow } ) More
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
SQLref | The reference number returned by FM.SQL.Execute function. | $SQLRef | |
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" | |
StartRow | The index of the start row in the current recordset. First row is 0. |
0 | Optional |
EndRow | The index of the end row in the current recordset. First row is 0. Last Row would be FM.SQL.RowCount-1. |
0 | Optional |
Result
Returns OK or error.
Description
Inserts records in FileMaker database from records in memory.This function allows to easily copy a lot of records from a query in FileMaker database into a FileMaker table.
Please provide field names in FileMaker. The order has to match those in the record set.
Due to passing in new field names, you can even rearrange values from one column to other while copying. In the SQL you can use functions for sums or join data from several tables together to fill a new table.
Use FM.ExecuteSQL.LastErrorMessage and FM.ExecuteSQL.LastError to see error message.
Reports an error if field name list doesn't match column count of the query result.
Function will fail if data types in source and dest fields do not match for assignment. e.g. date and time fields will not work, only timestamp fields.
For insert from SQL Connection into FileMaker database, please use SQL.InsertRecords.
Please don't overload the function, so better work in blocks of e.g. 1000 rows at a time.
Examples
Copy records:
# select some data
Set Variable [$Records; Value:MBS( "FM.SQL.Execute"; ""; "SELECT FirstName, LastName, Birthday FROM test" )]
# now insert them somewhere else
Set Variable [$r; Value:MBS( "FM.SQL.InsertRecords"; $Records; ""; "test"; "FirstName¶LastName¶BirthDay")]
# and free record set
Set Variable [$r; Value:MBS( "FM.SQL.Release"; $Records)]
See also
- FM.ExecuteSQL.LastError
- FM.ExecuteSQL.LastErrorMessage
- FM.SQL.Execute
- FM.SQL.Release
- FM.SQL.RowCount
- JSON.InsertRecords
- SQL.Execute
- SQL.InsertOrUpdateRecords
- SQL.InsertRecords
- XML.InsertRecords
Release notes
- Version 14.2
- Fixed a bug in FM.SQL.InsertRecords that prevented containers from being transferred.
- Version 13.2
- Changed field quoting for FM.SQL.InsertRecordsToSQL and Matrix.InsertRecordsToSQL to handle non ANSI quotes for MySQL/MariaDB.
- Version 13.1
- Fixed FM.SQL.InsertRecords, FM.SQL.InsertRecordsToSQL, Matrix.InsertRecordsToSQL and Matrix.InsertRecords to quote the table name for the SQL used internally.
- Version 7.2
- Changed FM.SQL.InsertRecordsToSQL to no longer quote by default.
Blog Entries
- MBS FileMaker Plugin, version 14.2pr5
- MBS FileMaker Plugin, version 13.1pr1
- Query FileMaker records as JSON
- MBS FileMaker Plugin 6.4 for OS X/Windows
- MBS FileMaker Plugin, version 6.4pr3
FileMaker Magazin
This function checks for a license.
Created 1st August 2016, last changed 15th October 2021
