Jump to content
Server Maintenance This Week. ×

The difference between a field Reference and a Litteral


This topic is 2867 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I've been working on a series of custom functions for building SQL queries. As I tailor these Custom Functions to meet many different situations and combine them in many different ways as well as making some recursive, I am running into situations where I can send a field reference and other times when I need to send a literal name of a field. What I mean by that is for instance is I am either sending ~SQLfield ( Table::field ) referencing the field or ~SQLfield ( "Table::field" ) using literal text.

If I send as a field reference such as ~SQLfield ( Table::field )
The following works 

Let ([

~field = GetValue ( Substitute ( GetFieldName ( ~fieldRef ); "::" ; "¶" ) ; 2 ) ;

~table = GetValue ( Substitute ( GetFieldName ( ~fieldRef ) ; "::" ; "¶" ) ; 1 ) ;
~table = ExecuteSQL (

"
SELECT DISTINCT BaseTableName FROM FileMaker_Tables

WHERE TableName = ?
"

;"";""; ~table
)

];

Quote ( ~table ) & "." & Quote ( ~field )

)

 

If I send as a field reference such as ~SQLfield ( "Table::field" )
The following works 

Let ([

~field = GetValue ( Substitute ( ~fieldRef ; "::" ; "¶" ) ; 2 ) ;

~table = GetValue ( Substitute ( ~fieldRef ; "::" ; "¶" ) ; 1 ) ;
~table = ExecuteSQL (

"
SELECT DISTINCT BaseTableName FROM FileMaker_Tables

WHERE TableName = ?
"

;"";""; ~table
)

];

Quote ( ~table ) & "." & Quote ( ~field )

)

 

The difference being in the use of GetFieldName ( ~fieldRef ) when sending a field reference which does not work when sending the field name as a litteral.

 

So my question is this.

Is there a way within the custom function to determine if the value being passed is a reference or a literal and adjusting accordingly so that passing either ~SQLfield ( Table::field ) or ~SQLfield ( "Table::field" ) could both work?

 

 

Edited by Ron Cates
Link to comment
Share on other sites

This topic is 2867 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.