SQLField ( )

Function stats

Average user rating
375
344
9999
Support
FileMaker 10.0 +
Date posted
08 February 2013
Version
1
Recursive function
No

Author Info
 Daniel Smith

8 functions

Average Rating 5.0

author_avatar



 

Function overview

Prototype

SQLField   ( fieldOrFieldName )


Parameters

fieldOrFieldName  field or field name to extract field name from. It can be from any TableOccurence, as that portion of the field name is removed.


Description

Tags:  Sql  

Quote a field name for use in a FileMaker SQL statement. Prevent hard-coding it's value.

Examples

Sample input

table::field


Sample output

"field"

 

Function code

/* SQLField ( fieldOrFieldName )

PURPOSE:
Quote a field name for use in a FileMaker SQL statement. Prevent hard-coding it's value.

PARAMETERS:
fieldOrFieldName (field, txt) field or field name to extract field name from. It can be from any TableOccurence, as that portion of the field name is removed.

DEPENDENCIES:
FileMaker Pro 10+

REVISIONS:
2011-MAR-25    - Created by Kevin Frank http://www.filemakerhacks.com/?p=1065
2011-JUL-01    - Dan Smith dansmith65@gmail.com
    - renamed from GFN to SQLField
    - added to documentation section
2012-AUG-10    - allow parameter to be a field or field name, change parameter name accordingly
####################################################################################################*/

Let (
[
    ~fieldName = If(
        IsValid( GetFieldName( fieldOrFieldName ) ) ;
        GetFieldName( fieldOrFieldName ) ;
        fieldOrFieldName
    ) ;
    ~separator = Position ( ~fieldName ; "::" ; 1 ; 1 ) ;
    ~fieldNameOnly = If(
        ~separator ;
        Right ( ~fieldName ; Length ( ~fieldName ) - ~separator - 1 ) ;
        ~fieldName
    )
] ;
    Quote ( ~fieldNameOnly )
)

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

    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/344

    Prototype: SQLField ( fieldOrFieldName )
    Function Author: Daniel Smith (http://www.fmfunctions.com/mid/375)
    Last updated: 08 February 2013
    Version: 1

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