Joshua Posted July 23, 2015 Posted July 23, 2015 (edited) Is the following query possible? If yes, what is missing from my format. If not, what are my alternatives to a achieve the same goal? ExecuteSQL ("SELECT Name FROM Customerdb WHERE ROW = 1"; ""; ""; "") or ExecuteSQL ("SELECT Name FROM Cutomerdb WHERE RECORD = 1"; ""; ""; "") Thanks in advance. Edited July 23, 2015 by Joshua
Kris M Posted July 24, 2015 Posted July 24, 2015 For the first item you should look at http://help.filemaker.com/app/answers/detail/a_id/12061/~/specifying-offset-and-fetch-first-clauses-in-filemaker-pro-using-the-executesql For the second question EOS is on the right track because the right answer is contingent on your response. Their are many ways to slice that cake.
Joshua Posted July 24, 2015 Author Posted July 24, 2015 Thank you for your response. On a particular script that I'm working on... I need to pull certain information one record at a time. Because some of the records will have the field blank the work around seems inefficient especially when I have to repeat it several times in different parts of the script: Set Variable [$CustomerIDs; Value:ExecuteSQL ("SELECT CustomerIDs FROM Customerdb"; ""; ""; "")] Set Variable [$CustomerID; Value:GetValue ($CustomerIDs; MainPage::RecordNum)] Set Variable [$CustomerName; Value: ExecuteSQL ("SELECT Name FROM Customerdb WHERE CustomerID = ?"; ""; ""; $CustomerID)] What I was wondering is it possible to do the following: Set Variable [$CustomerName; Value: ExecuteSQL ("SELECT Name FROM Customerdb WHERE ROW = ?"; ""; ""; MainPage::RecordNum)]
eos Posted July 24, 2015 Posted July 24, 2015 On a particular script that I'm working on... I need to pull certain information one record at a time. Gee … now everything is clear. Set Variable [$CustomerName; Value: ExecuteSQL ("SELECT Name FROM Customerdb WHERE ROW = ?"; ""; ""; MainPage::RecordNum)] What you mean is probably along the lines of ExecuteSQL ( " SELECT Name FROM Customerdb OFFSET " & Get (RecordNumber ) /* MainPage::RecordNum ? */ - 1 & " ROWS FETCH FIRST 1 ROW ONLY " ; "" ; "") OTOH, why not use Set Variable ( $listOfCustomerNames ; ExecuteSQL ( " SELECT Name FROM Customerdb " ; "" ; "" ) # [ or, if in context: List ( Customerdb::Name ) ]Set Variable [ $currentCustomerName ; GetValue ( $listOfCustomerNames ; Get ( RecordNumber ) ) ] Hard to tell what you need without knowing any details. 1
beverly Posted July 25, 2015 Posted July 25, 2015 eos has presented two very viable options! @Joshua the ExecuteSQL function in FM is not 'full-featured'. You cannot use all the available SQL functions that you might find in MySQL or MS SQL or Oracle or .... In case you haven't seen this, it might help you see what you can/cannot do with ExecuteSQL: http://filemakerhacks.com/2012/10/19/the-missing-fm-12-executesql-reference/ The blog article was just a start. I recommend that you get the PDF and the sample files. beverly
Recommended Posts
This topic is 3482 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