Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

ExecuteSQL calculation

Featured Replies

Hi,

It's my first time using executesql and I'm struggling with getting the results to show in my field. I basically want to get the latest record, based on the "obsdate" field for a given staff member from a table where they have numerous observations. I then want to show information from this record on a portal which will show the latest obs date for each member of staff which can then get sorted by date.

the code I've written is below but would return the key and date. How do I then loop through this to return the information I need?

 

Thanks in Advance.

Let ( [SQLString =
               ExecuteSQL ( "Select [__fk_Staffteacher], max(ObsDate) from tbl_TeacherEvaluationForm group by [__fk_staffteacher]"; ""; "" )
         ] ;

Evaluate(SQLString)
)

 

Let ( [

SQLString = ExecuteSQL ( "Select \"__fk_Staffteacher\", max(ObsDate) from \"tbl_TeacherEvaluationForm\" group by \"__fk_staffteacher\""; ""; "" )
         ] ;

Evaluate(SQLString)
)

escape quote tables and fields lead by underscores instead of brackets

http://www.mightydata.com/blog/filemaker-pro-12-adds-native-sql-queries/

 

also __fk_Staffteacher is not equal to __fk_staffteacher

Edited by Kris M

What is the point of using the Evaluate() function here? One would expect something more along the lines of:
 

Let (
SQLCommand = ... 
;
ExecuteSQL ( SQLCommand )
)

It would also be advantageous to calculate the field names using the GetFieldName() function, to protect the calculation against future field name changes.

  • 1 year later...

I would like to confirm something. It seems that GetFieldName ( ) is context independent. I would like to write robust sql using getfieldname( ) but was stuck thinking I'd need a relationship to the field. Can someone confirm that is not necessary.

It is context independent.

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.