sql.getTable ( )

Function stats

Average user rating
496
391
9999
Support
FileMaker 10.0 +
Date posted
25 February 2016
Last updated
25 February 2016
Version
Recursive function
No

Author Info
 Cristos L-C

7 functions

Average Rating None

author_avatar



 

Function overview

Prototype

sql.getTable  ( fullyQualfieidFieldObject )


Parameters

fullyQualfieidFieldObject  the fully-qualified (i.e., `Table::Field`) field name


Description

Tags:  sql  

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

Best used in combination with sql.getField (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.getTable ( ShoppingBaskets::__idBasket )


Sample output

"ShoppingBaskets"

 

Function code

/*
    sql.getTable ( fullyQualifiedFieldObject )
        - returns the plain text TABLE NAME in a format suitable for an SQL query
*/

Let ([
    ~field = fullyQualifiedFieldObject
;    ~fqFieldName = Case
    (    GetFieldName ( ~field ) = "?"
    ;        ~field
    ;    /* ELSE */ GetFieldName ( ~field )
    )
;    ~tableNamePos0 = 1
;    ~tableNamePos1 = Position ( ~fqFieldName ; "::" ; 0 ; 1 )
;    ~tableNameLength = ~tableNamePos1 - ~tableNamePos0
;    ~tableName = Middle ( ~fqFieldName ; ~tableNamePos0 ; ~tableNameLength )
];
    "\"" & ~tableName & "\""
)

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

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

    Prototype: sql.getTable( fullyQualfieidFieldObject )
    Function Author: Cristos L-C (http://www.fmfunctions.com/mid/496)
    Last updated: 25 February 2016
    Version: 1.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)