Hi,
Got it. It's clear now. Thanks. For the setEndRow(value), I thought the value (in this example) is 3, which is not known by the code. But it's the number(LIMIT) of returned records .
Thanks,
KL
Announcement
Collapse
No announcement yet.
X
-
Hi khanhlam,
DSRequest.setSortBy(-fieldname) is for descending
The fetch should return the record with id 3. How would the criteria be specified?Code:myRequest.setSortBy("idField"); myRequest.setEndRow(1); This should result in following SQL: SELECT ... FROM ... ORDER BY idField LIMIT 1;
Best regards
Blama
Leave a comment:
-
Hi,
Yes, this is server side DSRequest. Sorry I don't quite understand your answers.
Just want to clarify. So the DSRequest.setSortBy(fieldname) defaults to ascending, and DSRequest.setSortBy(-fieldname) is for descending. Is this correct?
The setEndRow() sets the index of the last requested record. But the code doesn't know about the index values. It just need to fetch the top record (smallest record id). For example, if there are 3 records with record ids of 3, 10, 15. The fetch should return the record with id 3. How would the criteria be specified?
Thanks,
KL
Leave a comment:
-
Hi khanhlam,
I'm pretty sure you are talking about the serverside DSRequest, correct? Clientside DSRequest is pretty obvious with the SortSpecifier.
Serverside, a "-" as prefix makes the sort descending (see the docs). NULLS FIRST/LAST is not possible, but you can add notNull criteria.
If you want to limit the result, see setEndRow().
Best regards
Blama
Leave a comment:
-
Sorting
Hi,
My code needs to do a fetch and get a list back in a certain order. I see in DSRequest there is a call to setSortBy(). What is the sort order (ascending/descending) when this is called? Is there a way to specify the sort order? Also if the code just need to fetch the top record (smallest record index), how should the criteria be specified?
Thanks,
KLTags: None
Leave a comment: