April 16, 201510 yr 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))
April 16, 201510 yr 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 April 16, 201510 yr by Kris M
April 16, 201510 yr 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.
February 6, 20179 yr 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.
Create an account or sign in to comment