Its possible to use "Do Select" method to return the last record of the query?
I need to retrieve the last value of the query, any exist a way to make it using only this webservice method?
From where are you using this method?
Can you adjust the whereclause to get only the one you need?
If not, usually webService method are called within a script/program or something similar. The method returns a list of string, you can convert it to an array, and access the last index.
Ex : array[array.length-1] depending on the language beeing used.
If your language support XML parsing or XML Node naviguating, you can read it directly with a similar approach.
I have been unable to pass an ORDER BY statement to the Where Clause which would allow you to sort it by a certain field, such as last modified, starting from most recent and then only return 1 row with the doSelect call. Without the ability to do that, where you can dictate the order of the results and choose to return only the first object returned, I do not believe this is possible with ONLY the doSelect method and no other logic. As Pier-Olivier said additional logic would need to be implemented on the returned data, or you can use RESTful web services which would allow you to filter in the way described above...
If I wanted the contact that was last updated:
Or the first contact created with a type of Customer:
More information on REST can be found at the links below:
REST HTTP Methods
Where Clause Resource Search
Search Result Sorting
I almost sure that this is not possible. But if you need to get some particular record in one web services call you can write your own spell and call it using callServerMethod. More info can be found here: SPEL: How to call SDM method using WebServies
One way to approach this might be to add something like this:
'and <column> = (select max(<column>) from <target table> where <other relevant conditions>)'
...to your select statement. Can you share with us the query that you are trying to retrieve the last record from?
You may use DoQuery to get a list handle and the count of records found, instead of DoSelect.
Then you would be able to access the last record values by using GetListValues method
Nevertheless, I still don't see a chance to influence the sort order using soap services
And never ever forget to free up the list handle by using the FreeListHandles method