Topics
All
MacOS
(Only)
Windows
(Only)
Linux
(Only, Not)
iOS
(Only, Not)
Components
Crossplatform Mac & Win
Server
Client
Old
Deprecated
Guides
Examples
Videos
New in version:
11.1
11.2
11.3
11.4
11.5
12.0
12.1
12.2
12.3
12.4
Statistic
FMM
Blog
FM.SQL.JSONColumn
Returns a column as JSON array.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
FM FMSQL JSON | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
SQLref | The reference number returned by FM.SQL.Execute function. | $SQLRef | |
Column | The column index to use from the SQL result. | 0 | |
Flags | The flags for the json creation. Pass 1 to get all values as text. Pass 2 to get all dates, times and timestamps in SQL format. Pass 8 to get containers as objects with name, size and data entries. (new in v12.1) |
1+2 | Optional |
Result
Returns JSON array or error.
Description
Returns a column as JSON array.Optionally we can return SQL dates, times and timestamps as SQL format.
Containers are returned as Base64 encoded data.
Examples
Query JSON array of all groups we have:
Set Variable [ $sql ; Value: MBS("FM.SQL.Execute"; ""; "SELECT DISTINCT \"Group\" FROM \"Contacts\" WHERE Length(\"Group\") > 0") ]
Set Variable [ $values ; Value: MBS("FM.SQL.JSONColumn"; $SQL; 0) ]
Set Variable [ $r ; Value: MBS("FM.SQL.Release"; $SQL) ]
Show Custom Dialog [ "Values" ; $values ]
Query two JSON arrays, one for group names and ID list:
Set Variable [ $sql ; Value: MBS("FM.SQL.Execute"; ""; "SELECT DISTINCT \"ID\", \"Group\" FROM \"Contacts\" WHERE Length(\"Group\") > 0") ]
If [ MBS("IsError") ]
Show Custom Dialog [ "Error" ; $sql ]
Else
Set Variable [ $IDs ; Value: MBS("FM.SQL.JSONColumn"; $SQL; 0) ]
Set Variable [ $Groups ; Value: MBS("FM.SQL.JSONColumn"; $SQL; 1) ]
Set Variable [ $r ; Value: MBS("FM.SQL.Release"; $SQL) ]
Show Custom Dialog [ "Values" ; $IDs & ¶ & $Groups ]
End If
See also
Release notes
- Version 12.1
- Added flag value 8 for FM.SQL.JSONColumn, Matrix.JSONRecord, Matrix.JSONRecords, FM.SQL.JSONRecord and FM.SQL.JSONRecords to return containers as JSON objects with data, size and name.
- Version 12.0
- Fixed JSON functions to return NULL for numbers with no content, e.g. empty text. This affects JSON.CreateNumber, Dictionary.ToJSON, FM.SQL.JSONColumn, FM.SQL.JSONRecord and FM.SQL.JSONRecords functions.
- Version 10.5
- Added FM.SQL.JSONColumn function.
Blog Entries
FileMaker Magazin
Created 2nd October 2020, last changed 12nd March 2022
FM.SQL.InsertRecordsToSQL - FM.SQL.JSONRecord
Feedback: Report problem or ask question.
