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

FM.ExecuteSQL.LastError

Queries the last error code from an SQL call

Component Version macOS Windows Linux Server iOS SDK
FM FMSQL 1.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "FM.ExecuteSQL.LastError" )

Parameters

none

Description

Queries the last error code from an SQL call
Set by FM.InsertRecord, FM.SQL.Execute, FM.ExecuteSQL, FM.ExecuteFileSQL, FM.ExecuteSQLOnIdle and other SQL related functions.

In general error 8309 is a semantic error, so something is wrong in your SQL. 8310 is a syntax error, something in the SQL is not correctly parsed.
Error 8309 means you did pass wrong data type, like string for a number.
See also FM.ExecuteSQL.LastErrorMessage.

Examples

Get Last SQL Error

MBS( "FM.ExecuteSQL.LastError")

Get the last error code:

Let([
    sql = "SELECT * FROM Test";
    r = MBS("FM.ExecuteFileSQL"; ""; sql);
    errorCode = MBS( "FM.ExecuteSQL.LastError" )
]; errorCode)

Example result: 8309

See also

Example Databases

Blog Entries

This function is free to use.

Created 18th August 2014, last changed 25th June 2026


FM.ExecuteSQL - FM.ExecuteSQL.LastErrorMessage


MarkDown version: FMExecuteSQLLastError.md