Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Guides   Examples
New in version: 7.4   7.5   8.0   8.1   8.2   8.3   8.4   8.5   9.0   9.1    Statistic  


Inserts or updates a record in a table in one line.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
FM FMSQL 6.0 Yes Yes Yes Yes Yes
MBS( "FM.InsertOrUpdateRecord"; FileName; TableName; IDField1; IDValue1; FieldName; FieldValue )   More


Parameter Description Example value
FileName The file name of where the table is inside. Can be empty to look for the table in all files. Get(FileName)
TableName The name of the table to insert record into. "Assets"
IDField1 The name of the field which provides an unique ID for each record, so we can identify the field. "ID"
IDValue1 The value for the ID field to identify the record.
Data type of parameter must match the data type of the field.
FieldName A field name to set. "Model"
FieldValue A field value to use for setting the field in the parameter before.
Data type of parameter must match the data type of the field.


Returns OK or error.


Inserts or updates a record in a table in one line.
If the insert fails due to duplicate ID, we will update the record values.
You pass to this function table name (and optional filename).
To identify the record you pass the name of the ID field and the value for the record. The ID field must be unique.
Than you pass one pair of field name and value for each field you like to set in the new record.

This function combines FM.InsertRecord and FM.UpdateRecord. If the ID is already used, we update, else we insert a new record.

For one ID field, please use FM.InsertOrUpdateRecord, for 2 ID fields FM.InsertOrUpdateRecord2 and for three ID fields FM.InsertOrUpdateRecord3.

This function is broken in version 6.4 as it returns always a SQL error for insert. Please use 6.5 or newer.
With plugin version 7.2 or later, you can specify fields and table via IDs and the plugin will lookup them for you at runtime. Table IDs and table names must be unique across all open files for this to work correctly.

With plugin version 8.4 or newer, you can use GetFieldName() function to query field names and the plugin removes the table prefix with :: in the field name before passing it to SQL engine.


Update a record:

MBS( "FM.InsertOrUpdateRecord";
""; "Asset Management"; /* file and table name */
"Asset ID"; "1"; /* ID field and value */
"Information"; "Just a test"; /* first field and value */
"Category"; "BestItems" ) /* second field and value */

See also

Blog Entries

Created 5th December 2015, last changed 31st July 2018

FM.InitMessageFilter   -   FM.InsertOrUpdateRecord2

Feedback: Report problem or ask question.

MBS Xojo Plugins