I have 535 Contact records in my Developer account. I am finding that the following query:
SELECT Id,FirstName,Lastname FROM Contact LIMIT 205 OFFSET 190
returns 200 records from Database.query(), while this query:
SELECT Id,FirstName,Lastname FROM Contact LIMIT 199 OFFSET 190
returns 199. I suspect there is an implicit 200 maximum on the value for LIMIT, but I can't find it documented anywhere, and no error is raised when I use these higher values.
Attribution to: Jeff Trull
Possible Suggestion/Solution #1
The optional LIMIT clause allows you to specify the maximum number of rows returned in the text query, up to 200. If unspecified, then the default is 200, which is the largest number of rows that can be returned.
That link is for SOSL, but maybe the same applies for SOQL?
Attribution to: Peter Knolle
Possible Suggestion/Solution #2
The LIMIT
clause has no limit in and of itself. It's limited to the context in which it's used. If it's used in Apex code it's limited to the total governor limit for SOQL rows, which is currently 50,000. If it's used in a query via the Web Service API then there is no limit.
The issue you're running into appears solely to be an issue with using the OFFSET
clause and LIMIT
together.
Attribution to: E.J. Wilburn
Possible Suggestion/Solution #3
When using the offset clause the query will only return the first batch of records in the resultset at most. In this case, it looks like the batch size is 200. To get additional records, reexecute the query with a larger offset value.
Attribution to: user485
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/348