Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

FM.QueryFieldsForTableName

Queries the field names of all fields in the given table.

Component Version macOS Windows Linux Server iOS SDK
FM FMSQL 3.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ✅ Yes
MBS( "FM.QueryFieldsForTableName"; TableName { ; FileName } )   More

Parameters

Parameter Description Example Flags
TableName The table name to query. "test"
FileName The database file name to look into.
If empty or missing, we look in current database.
(new in 6.2)
"Contacts" Optional

Result

Returns field names of fields separated by return.

Description

Queries the field names of all fields in the given table.
See also FM.QueryFieldsForBaseTableName.

Needs permissions to query your database schema via SQL.

Examples

Query field names for Contacts table:

MBS( "FM.QueryFieldsForTableName"; "Contacts" )

Query fields for Kontakte in Kontakte database:

MBS( "FM.QueryFieldsForTableName"; "Kontakte"; "Kontakte" )

Build quoted list of fields:

"\"" & substitute(MBS( "FM.QueryFieldsForTableName"; "Aufgaben" ); ¶; "\"; \"") & "\""

Query fields as JSON:

While([
// query field list
~fields = MBS("FM.QueryFieldsForTableName"; Get(LayoutTableName));
$$json = "{}"
];
// loop over field list
ValueCount(~fields ) > 1;
[
// get field name without spaces and the value from the field
fieldName = Substitute(GetValue(~fields ; 1); " "; "");
fieldValue = Evaluate(Get(LayoutTableName) & "::" & GetValue(~fields; 1));
// add to json as text value
$$json = JSONSetElement ( $$json ; fieldName; fieldValue ; JSONString );
// next
~fields = MiddleValues ( ~fields ; 2; ValueCount(~fields )-1 )
];
$$json)

See also

Release notes

Blog Entries

This function checks for a license.

Created 18th August 2014, last changed 6th May 2023


FM.QueryFieldsForBaseTableName - FM.QueryTableNames