JSON.eSQL ( field ; modifier ; table ; join ; condition ; group ; order )
Returns ExecuteSQL as a JSON in FileMaker Data API structure
Be the first to rate this function Log in to vote
Jonni™ - Show more from this author |
"messages" :
[
{
"code" : "0",
"message" : "OK"
}
],
"response" :
{
"data" :
[
{
"fieldData" :
{
"d_name_T" : "Paul's Boutique",
"d_state_J" : 0,
"d_termsPayment_N" : 75
}
},
{
"fieldData" :
{
"d_name_T" : "Joe's Restaurant",
"d_state_J" : 0,
"d_termsPayment_N" : 75
}
}
],
"dataInfo" :
{
"database" : "myApp",
"fieldCount" : 30,
"foundCount" : 2,
"layout" : "N/A",
"returnedCount" : 2,
"table" : "customer",
"totalRecordCount" : 2
}
}
}
Function definition: (Copy & paste into FileMaker's Edit Custom Function window)
This is an updated function combining SQLasJSON and fullTableSQLasJSON into one function
Input parameters:
JSON.eSQL ( field ; modifier ; table ; join ; condition ; group ; order )
BD Link : https://www.briandunning.com/cf/2786
Outputs a JSON array that follows the same structure as FileMaker Data API
1 : field (required) : list field names separated by a comma or request full table entering a *
2 : modifier (optional) : the modifier will be injected after SELECT. Example "DISTINCT", which will resolve to SELECT DISTINCT myfield1, myfield2...
3 : join (optional) : declare a join relationship. Example "JOIN myTable ON matches", which will resolve to ...JOIN myTable ON matches...
4 : condition (optional) : declare a condition in this parameter. Example "WHERE id = 123"
5 : group (optional) : declare a result grouping. Example "myField", which will resolve to GROUP BY myField...
6 : order (optional) : declare result order/sort. Example "myField ASC", which will resolve to ORDER BY myField ASC...
NOTE : When using joins you need to declare all fields. * is not supported for joins.
This is an updated function combining SQLasJSON and fullTableSQLasJSON into one function
New in this version
1. declare * for full table resolve
2. support for modifier, join, group and sort
3. improved error handling using ExecuteSQLe error responses when supported (FMP21.1.1+)
4. follows FileMaker Data API response structure
5. detects and declares JSONNumber for numbers only values and JSONString for other values
Written by jonni@me.com
V 3.0
Comments
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.