Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted (edited)

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
Posted

Maybe. But maybe you'd be better off with separate functions.

Posted

That's actually what I have done. I was just hoping there was a way so I could consolidate them.

Posted

Bam! Racked my brain all day Friday trying to figure it out, came in this morning and there it is!

Thanks Wim :)

This topic is 3078 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.