Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old


Execute the SQL Statement against a FileMaker database.

Component Version macOS Windows Linux Server iOS SDK
FM 12.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "FM.ExecuteFileSQLValue"; FileName; SQL Statement { ; Params... } )   More


Parameter Description Example Flags
FileName The target database name. Can be empty to not limit query to one database.

Using a table in another database file may require you adding the other file as an external data source and adding the external table to your relationship graph to grant access.
SQL Statement SQL Statement as a Text string
Params... Optional, pass here parameters. One parameter to this function for each parameter you want to pass to the SQL statement. 123 Optional


Returns value or error.


Execute the SQL Statement against a FileMaker database.
Just like FM.ExecuteFileSQL, but only returns first value of first row in result. This preserves the value type without conversion to text.

This function takes variable number of parameters. Pass as much parameters as needed separated by the semicolon in FileMaker.
Please repeat Params parameter as often as you need.


Query one field:

MBS( "FM.ExecuteFileSQLValue"; ""; "SELECT \"First\" FROM \"Contacts\" WHERE ID=1")

Query container and check the data type:

MBS("FM.DataType"; MBS( "FM.ExecuteFileSQLValue"; ""; "SELECT \"PDFFile\" FROM \"Contacts\" WHERE ID=1"))

Example result: "container"

Query date:

MBS( "FM.ExecuteFileSQLValue"; ""; "SELECT DATE() FROM Contacts")

Example result: Returned "30.12.2021" in Germany on that day.

Query RowID for UUID field:

MBS( "FM.ExecuteFileSQLValue"; ""; "SELECT RowID FROM \"Contacts\" WHERE UUIdentiifer=?"; $UUID)

Use an insert ID to get the primary key of a new records:

Set Variable [ $InsertID ; Value: Get(UUIDNumber) ]
Set Variable [ $r ; Value: MBS("FM.InsertRecord"; Get(FileName); "Assets";
    "Name"; "Test";
    "Vendor"; "Company Ltd.";
    "InsertID"; $InsertID) ]
Set Variable [ $primaryKey ; Value: MBS( "FM.ExecuteFileSQLValue"; Get(FileName); "SELECT \"PrimaryKey\" FROM \"Assets\" WHERE \"InsertID\" = ?"; $InsertID) ]
Show Custom Dialog [ "New primary key: " & $primaryKey ]

See also

Release notes

Blog Entries

This function checks for a license.

Created 30th December 2021, last changed 7th May 2024

FM.ExecuteFileSQLOnIdle - FM.ExecuteSQL