Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4    Statistic  

FM.InsertRecordTSV

Inserts records based on tab/return separated text.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
FM FMSQL 5.3 Yes Yes Yes Yes Yes

MBS( "FM.InsertRecordTSV"; InsertFileName; InsertTableName; FieldNames; Text { ; FieldName; FieldValue } )

Parameters

Parameter Description Example value
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"
Text The text to import in TSV format. This means tab character between fields and newline character for new records "Bob Miller 12345 New York"
FieldName Optional
A field name to set.
"Model"
FieldValue Optional
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.
"Test"

Result

Returns number or error.

Description

Inserts records based on tab/return separated text.
This function allows for easy importing of text to create a log of records.
Filename parameters can be empty.
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. The fields must be of type text. You can later use a script to copy values in whatever format you need.
Returns number of records added.

For XML, please check XML.Import function. For splitting values with delimiter into a list, please use QuickList.New which also works with comma, tab, newline or other characters.

With plugin version 6.2 or newer you can pass one pair of field name and value for each extra field you like to set in the new records. e.g. a reference ID.

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.

Examples

Import records from text:

Delete All Records [No dialog]
Set Variable [$fields; Value:"FirstName¶LastName¶City"]
Set Variable [$r; Value:MBS("FM.InsertRecordTSV"; ""; "Contacts"; $fields; Import::ImportText)]

Import some contacts with passing import ID/timestamp:

MBS( "FM.InsertRecordTSV"; "Contacts.fmp12"; "Contacts"; "FirstName¶LastName¶City"; $tsv; "ImportID"; $importID; "ImportDate"; Get(CurrentHostTimeStamp))

See also

Example Databases


FM.InsertRecordQueryIgnoreDuplicates   -   FM.InsertSetUpdateProgressDialog

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins