fm_sql_select


mixed fm_sql_select ( string $sql_query [, int $field_separator [, int $record_separator [, string $file_name [, arguments... ]]]] )


 

Description


Allows you to perform SQL SELECT queries against FileMaker tables and return the results.

This function is similar to the ExecuteSQL function that was added in FileMaker 12.

See FileMaker’s SQL Reference for more info on SQL support in FileMaker.

A new, potentially faster, SQL function was introduced in FileMaker 13. This function returns the result as text and reduces the overhead required to generate the result. Keep this in mind if you’re working with large data sets as you may want to use fm_sql_select instead of fm_sql_select_ex. Note that fm_sql_select uses the API function ExecuteFileSQLTextResult (if available) whereas fm_sql_select_ex uses ExecuteFileSQL.

Parameters


sql_query (required)
A valid SQL SELECT statement. The query must begin with “SELECT”.

field_separator (optional)
ASCII or Unicode character code. The pipe character “|” (code 124) is the default. Pass in 0 to use the default.

record_separator (optional)
ASCII or Unicode character code. The return character “¶” (code 13) is the default. Pass in 0 to use the default.

file_name (optional) (only available in FileMaker 11 or higher)
Allows you to specify the name of the file in which to run the query. The current file will be used by default so this is only needed if the table(s) you’re querying are in a different file. Note that the file must be open.

arguments... (optional) (only available in FileMaker 11 or higher)
Any number of optional arguments corresponding to the dynamic parameters (?’s) in your query.

 

Return


Returns the result of the query or false if an error occurs.

Most errors are caused by invalid SQL statements. Use fm_get_last_error to get error details.

 

Errors


106 Invalid parameter (returned when query doesn’t begin with “SELECT”)

 

Example 1 - Concatenate 3 strings
// Todo

Change Log

VersionDescription
3.0.0Added optional parameters: file_name and arguments...