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: 8.0   8.1   8.2   8.3   8.4   8.5   9.0   9.1   9.2   9.3    Statistic  


This is similar to FM.ExecuteFileSQL, except that it waits until idle to execute.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
FM FMSQL 6.5 Yes Yes Yes Yes Yes
MBS( "FM.ExecuteFileSQLOnIdle"; SQL Statement; FileName { ; Column Delimiter; Record Delimiter; Params } )   More


Parameter Description Example value
SQL Statement the SQL statement
FileName The file name of the database. Get(FileName)
Column Delimiter Optional
Columns Separator, only used with SELECT statement. Default is TAB
Record Delimiter Optional
Record Separator, only used with SELECT statement, Default is Return
Params Optional
Optional, pass here parameters. One parameter to this function for each parameter you want to pass to the SQL statement.


Returns OK or error.


This is similar to FM.ExecuteFileSQL, except that it waits until idle to execute.
You run a script pause after using this function to give it time to execute.
See the other function for more info.
Seems like on FileMaker 11 you get LastError 8310 if you use fields with underscore in the name. You avoid that by placing the field names in quotes.
Use FM.ExecuteSQL.LastErrorMessage and FM.ExecuteSQL.LastError to see error message.


Create a new text field in a table:

MBS("FM.ExecuteSQLOnIdle";"ALTER TABLE TestTable ADD MyField varchar")

Create in a script and check error:

# set command to run
Set Variable [ $r ; Value: MBS("FM.ExecuteFileSQLOnIdle"; "ALTER TABLE Kontakte ADD MyField varchar"; "Kontakte.fmp12") ]
# Make pause to run it
Pause/Resume Script [ Duration (seconds): ,1 ]
# Check error status
Set Variable [ $errorNumber ; Value: MBS( "FM.ExecuteSQL.LastError" ) ]
Set Variable [ $errorMessage ; Value: MBS( "FM.ExecuteSQL.LastErrorMessage" ) ]

Create a field:

Set Variable [ $r ; Value: MBS("FM.ExecuteFileSQLOnIdle";"ALTER TABLE TestTable ADD MyField varchar"; Get(FileName)) ]
Pause/Resume Script [ Duration (seconds): ,1 ]
If [ MBS("FM.ExecuteSQL.LastError") ≠ 0 ]
    Show Custom Dialog [ "Error adding column" ; MBS("FM.ExecuteSQL.LastError") & ": " & MBS("FM.ExecuteSQL.LastErrorMessage") ]
    Show Custom Dialog [ "Removed Column" ; "OK" ]
End If

See also

Blog Entries

Created 16th October 2016, last changed 5th November 2018

FM.ExecuteFileSQL   -   FM.ExecuteSQL

Feedback: Report problem or ask question.

MBS Xojo PDF Plugins