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: 9.2   9.3   9.4   9.5   10.0   10.1   10.2   10.3   10.4   10.5    Statistic    FMM    Blog  

FM.SQL.JSONColumn

Returns a column as JSON array.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
FM 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.
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 10.5
    • Added FM.SQL.JSONColumn function.

Created 2nd October 2020, last changed 2nd October 2020


FM.SQL.InsertRecordsToSQL   -   FM.SQL.JSONRecord

Feedback: Report problem or ask question.




Links
MBS Xojo blog