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.0   6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3    Statistic  

FM.SQL.Execute

Execute the SQL Statement against a FileMaker database.

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

MBS( "FM.SQL.Execute"; FileName; SQL Statement { ; Params } )

Parameters

Parameter Description Example value
FileName The target database name. Can be empty to not limit query to one database. ""
SQL Statement SQL Statement as a Text string
Params Optional
Optional, pass here parameters. One parameter to this function for each parameter you want to pass to the SQL statement.
123

Result

Returns reference number or error.

Description

Execute the SQL Statement against a FileMaker database.
This function requires FileMaker 11 or newer. Please use FM.ExecuteSQL on FileMaker 10 or older.
Returns a SQL Reference, so you can use functions like FM.SQL.RowCount, FM.SQL.FieldCount, FM.SQL.Field and FM.SQL.FieldType to query result. Don't forget to use FM.SQL.Release to release the result from memory when you are done with it.

Examples

Query only first row:

MBS( "FM.SQL.Execute"; ""; "SELECT * FROM ProductImages FETCH FIRST 1 ROWS ONLY")

SELECT records

MBS("FM.SQL.Execute"; ""; "select * from Contacts")

Select with parameter:

MBS("FM.SQL.Execute"; ""; "select Menge from Boxen where Artikel_Nr=? ORDER BY Menge DESC"; "ABC123")

Query some values:

Set Variable [$sql; Value:MBS( "FM.SQL.Execute"; ""; "select * from Clients")]
If [MBS("IsError")]
    Show Custom Dialog ["SQL error"; $sql]
Else
    Show Custom Dialog ["SQL result"; "got " & MBS( "FM.SQL.RowCount"; $sql ) &" rows with each " & MBS( "FM.SQL.FieldCount"; $sql ) & " …"]
    Set Variable [$r; Value:MBS( "FM.SQL.Release"; $sql )]
End If

See also

Example Databases


FM.SQL.CSV   -   FM.SQL.Field

Feedback: Report problem or ask question.




Links
MBS Xojo blog