sql.getField ( )

Function stats

Average user rating
496
390
9999
Support
FileMaker 10.0 +
Date posted
25 February 2016
Version
1
Recursive function
No

Author Info
 Cristos L-C

7 functions

Average Rating None

author_avatar



 

Function overview

Prototype

sql.getField  ( fullyQualifiedFieldObject )


Parameters

fullyQualifiedFieldObject  the fully-qualified (Table::Field) field


Description

Tags:  sql  

Gets the name of a field from a fully-qualified field object. Useful for protecting against field-renaming.

Best used in combination with sql.getTable (for similar protection against field renaming).

Example usage in a full query:
Let (
[ ~sqlQuery = List
( "SELECT " & sql.getField ( TableName::__uuid )
; "FROM " & sql.getTable ( TableName::__uuid )
; "WHERE " & sql.getField ( TableName::idEmployee ) & " = ?"
)
]
; ExecuteSQL
( ~sqlQuery
; "," ; "¶"
; $idEmployee
)
)

Examples

Sample input

sql.getField ( TableName::__uuid )


Sample output

"__uuid"

 

Function code

/*
sql.getField ( fullyQualifiedFieldObject )
- returns the plain text FIELD NAME in a format suitable for an SQL query
*/
Let ([
~field = fullyQualifiedFieldObject
; ~fqFieldName = Case
( GetFieldName ( ~field ) = "?"
; ~field
; /* ELSE */ GetFieldName ( ~field )
)
; ~fieldNamePos0 = Position ( ~fqFieldName ; "::" ; 0 ; 1 ) + Length ( "::" )
; ~fieldNamePos1 = Length ( ~fqFieldName )
; ~fieldNameLength = ~fieldNamePos1 - ~fieldNamePos0 + Length ( "::" )
; ~fieldName = Middle ( ~fqFieldName ; ~fieldNamePos0 ; ~fieldNameLength )
];
"\"" & ~fieldName & "\""
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/390

    Prototype: sql.getField( fullyQualifiedFieldObject )
    Function Author: Cristos L-C (http://www.fmfunctions.com/mid/496)
    Last updated: 25 February 2016
    Version: 1

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)