Brian Dunning's FileMaker Custom Functions

SQL_Creator_Select ( wrapped ; table_name ; layout_name ; using_field_from ; list_fields_only ; use_distinct ; key_field_list ; separator_for_records ; separator_for_fields )

helps to create sql select statements using field names of current table

  Average rating: 3.5 (2 votes) Log in to vote

Thomas Siebert   Thomas Siebert - Show more from this author
http://www.t-seabird.de

Share on Facebook Share on Twitter

  Sample input:
SQL_Creator_Select ( 1 ; "" ; "" ; 0 ; 0 ; 1 ; "__id_pk¶_id_great" ; "" ; "" )
  Sample output:
ExecuteSQL ( "SELECT DISTINCT

\"__active\",
\"__id_othertable\",
\"__id_country\",
\"__id_project\",
\"Address\",
\"Name_Last\",
\"Name_First\"

FROM \"person\" WHERE \"__id_pk\"=? AND \"_id_great\"=?" ; "" ; "" ; $id_pk ; $id_great )

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This function creates an SQL 'SELECT' statement including any field that is present on the current layout or the current table.
The parameters influence the way how the SQL statement will be presented.

wrapped: empty or 0 = auto, 1 = wrapped, 2 = not wrapped
table_name: enter any table name of the current file to create an SQL Statement for that table. If blank the current table will be used.
layout_name: enter any layout name based on the current table name to create an SQL Statement on the fields of the table presented by that layout. If blank the current layout will be used
using_field_from: empty or 0 = current table fields, 1 = current table fields present in visible layout, 2 = under consideration
list_fields_only: only the masked fields are present without SQL SELECT statement
use_distinct: add DISTINCT to avoid duplicated values
key_field_list: a list of field names adding as a WHERE statement with unlimited keys. those name will also be added as key variables on the end of the execute sql construction. Leading underscores will be eliminated for those variables.
separator_for_records: if empty then ¶
separator_for_fields: if empty then ,


Erzeugt eine einfache SQL SELECT Abfrage.
Die Liste der Felder wird aus dem gerade sichtbaren Layout übernommen oder kann manuell eingegeben werden.
Die Felder werden in maskierte Anführungszeichen gesetzt und per Komma getrennt.

wrapped: leer oder 0 = automatisch, 1 = umbrochen, 2 = nicht umbrochen
table_name: gib den Namen einer Tabelle an für welche eine SELECT Abfrage erzeugt werden soll. Wenn hier kein Wert übergeben wird wird die aktuelle Tabelle verwendet.
layout_name: hier kann der Name eines Layouts eingegeben werden. Die Abfrage kann so auf die im Layout enthaltenen Felder Begrenzt werden. Falls leer wird das aktuelle Layout verwendet.
using_field_from: legt fest welche Felder letztendlich übernommen werden. leer oder 0 = alle Felder aus der angegebenen Tabelle, 1 = Alle im angegebenen Layout sichtbaren Felder der angegebenen Tabelle
list_fields_only: nur die maskierten Felder werden aufgelistet, ohne SQL SELECT Abfrage
use_distinct: fügt DISTINCT hinzu um doppelte Werte bei der Abfrage zu vermeiden.
key_field_list: eine Liste von Feldnamen die als Schlüssel für die WHERE Abfrage hinzugefügt werden können. Diese Feldnamen werden zusätzlich als Schlüsselvariablen am Ende der SQL Abfrage eingesetzt. Führende Unterstriche werden dort entfernt.
separator_for_records: falls leer dann ¶
separator_for_fields: falls leer dann ,

 

Comments

Georg Löffler   Georg Löffler, Mauerbach/Wien
Jul 5, 2018
list_fields_only: nur die maskierten Felder werden aufgelistet funktioniert nicht
es werden immer alle Felder angezeigt
 
Thomas Siebert   Thomas Siebert
Jul 5, 2018
Der Beschreibungstext ist wohl etwas missverständlich:

Bei dieser Option entfällt der Rest der SQL Abfrage, bzw die komplette Abfrage bis auf die Felder.

dann müsste das Ganze etwa so aussehen:

\"__active\",
\"__id_othertable\",
\"__id_country\",
\"__id_project\",
\"Address\",
\"Name_Last\",
\"Name_First\"
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: