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
MBS( "FM.SQL.JSONColumn"; SQLref; Column { ; Flags } )   More

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

Blog Entries

This function checks for a license.

Created 2nd October 2020, last changed 12nd March 2022


FM.SQL.InsertRecordsToSQL - FM.SQL.JSONRecord