Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
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
- MBS FileMaker Plugin, version 11.6pr3
- New in MBS FileMaker Plugin 10.5
- MBS FileMaker Plugin, version 10.5pr2
FileMaker Magazin
This function checks for a license.
Created 2nd October 2020, last changed 12nd March 2022