aguest Posted April 16, 2015 Posted April 16, 2015 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))
Kris M Posted April 16, 2015 Posted April 16, 2015 (edited) 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, 2015 by Kris M
comment Posted April 16, 2015 Posted April 16, 2015 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.
bcooney Posted February 6, 2017 Posted February 6, 2017 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.
Recommended Posts
This topic is 2903 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 accountSign in
Already have an account? Sign in here.
Sign In Now