Jump to content

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

Recommended Posts

Posted (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 by Joshua
Posted

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)]

 

Posted

 

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.

  • Like 1
Posted

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

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 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.