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


Queries the last error message from an SQL call

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




Returns error message.


Queries the last error message from an SQL call
Set by FM.InsertRecord, FM.SQL.Execute, FM.ExecuteSQL, FM.ExecuteFileSQL, FM.ExecuteSQLOnIdle and other SQL using functions.
If last error code was 0 (no error), you get an empty string.
Error may be something like this:
ERROR: FQL0007/(1:7): The column named "fieldname" does not exist in any table in the column reference's scope.

FQL0001There is an error in the syntax of the query.
FQL0002The table named "?0" does not exist.
FQL0003The table named "?0" already exists in this query.
FQL0004The query is too complex. The maximum number of tables has been exceeded.
FQL0005Expressions involving aggregations are not supported.
FQL0006"The column named "?0" appears in more than one table in the column reference's scope."
FQL0007The column named "?0" does not exist in any table in the column reference's scope.
FQL0008The table named "?0" does not exist in the column reference's scope.
FQL0009The column named "?1" does not exist in table "?0".
FQL0010The literal value "?0" is not a valid DATE, TIME or TIMESTAMP.
FQL0011Predicate must contain a logical operation (=, <, OR, AND, IS NULL, ...).
FQL0012The ordinal reference "?0" in the ORDER BY clause is not valid.
FQL0013Incompatible types in assignment.
FQL0014The number of values in a VALUES row value constructor does not match the number of values in the target.
FQL0015The number of values in an INSERT...SELECT statement does not match the number of values in the target.
FQL0016A subquery contains an illegal outer reference to a column in the INSERT's target table.
FQL0017An expression contains data types that cannot be compared.
FQL0018An expression contains incompatible data types.
FQL0019The result data type of a CASE expression cannot be inferred; they are all NULL.
FQL0020An invalid number of parameters was supplied to the function "?0"
FQL0021Parameter number ?0 to the function "?1" is not of the correct type.
FQL0022A subquery expression must have exactly one value in the SELECT list.
FQL0023A CAST expression requested an invalid data type conversion.
FQL0024A reference to ROWID must be qualified if more than one table is present in the query.
FQL0025All non-aggregated column references in the SELECT list and HAVING clause must be in the GROUP BY clause.
FQL0026The number of columns in both inputs to a UNION operation must be the same.
FQL0027The data types of corresponding columns in the inputs to a UNION operation must be the same.
FQL0028Field repetitions must be numeric and between 1 and ?0.
FQL0029A field repetition in the SET clause of an UPDATE statement must be a constant.
FQL0030"?0" is an invalid function.
FQL0031The the parameter's type cannot be inferred in this context. At least one query parameter must be an expression, a column or a constant.
FQL0032A query may contain either named parameters or dynamic parameters, but not both.
FQL0033Column names in FROM clause subqueries must be unique.
FQL0034The number of output columns in a FROM clause subquery must match the number of columns in the table's name list.
FQL0035Cursor support is not enabled for this query.
FQL0036A cursor with the name "?0" already exists.
FQL0037There is no cursor with the name "?0".
FQL0038The cursor "?0" is already open.
FQL0039The cursor "?0" is not open.
FQL0040The target cursor "?0" does not reference a query that is valid for WHERE CURRENT OF .
FQL0041The target cursor "?0" does not reference the same table as the current statement.
FQL0042The default value for column "?0" does not match the column's data type.
FQL0043The string "?0" is not a valid stream name.
FQL0044The column "?0" is not valid in this context. The targets of GETAS and PUTAS must be Container fields.

See also FM.ExecuteSQL.LastError. Use FM.ExecuteSQL.LastSQL to get the SQL command.

If you get error "FQL0013 Incompatible types in assignment" when using FM.InsertRecord or similar functions, the data type doesn't match. For a numeric field, you can use GetAsNumber() in the call to make sure the value is numeric. Same for date/time/timestamp fields and of course text fields, which may need a GetAsText().

See also

Example Databases

Blog Entries

This function is free to use.

Created 18th August 2014, last changed 16th August 2021

FM.ExecuteSQL.LastError - FM.ExecuteSQL.LastSQL