You need to sign in to do that
Don't have an account?

How can I filter a SOQL query by the object's row index when there isn't such column?
More specifically, I want to create various individual SELECT queries in which I retrieve the first 1000 results of the object, than the next 1000 and so on.
Example:
SELECT Id, Name FROM Account WHERE rowIndex BETWEEN 1 AND 1000;
SELECT Id, Name FROM Account WHERE rowIndex BETWEEN 1001 AND 2000;
(...)
The thing is, the column "rowIndex" (or an equivelent one) does not exist in the object (column "Id" does not qualify).
So, how can I retrieve only 1000 results each time of the query: "SELECT Id, Name FROM Account"?
Thank you.
Example:
SELECT Id, Name FROM Account WHERE rowIndex BETWEEN 1 AND 1000;
SELECT Id, Name FROM Account WHERE rowIndex BETWEEN 1001 AND 2000;
(...)
The thing is, the column "rowIndex" (or an equivelent one) does not exist in the object (column "Id" does not qualify).
So, how can I retrieve only 1000 results each time of the query: "SELECT Id, Name FROM Account"?
Thank you.
For fetching records there is one inbuilt function i.e. OFFSET but it will work only for 2000 records. For more details refer to heading 'OFFSET' in the index in below pdf:
https://resources.docs.salesforce.com/sfdc/pdf/salesforce_soql_sosl.pdf
Example to use offset is: The result set for the preceding example would be a subset of the full result set, returning rows 11 through 30 of the full set.
Please mark this as best answer if it helps.
Thanks,
Neetu
Thanks for taking the time to answer.
I have around 100000 records and since OFFSET is limited to 2000 records, it won't work right?
Why dont you raise a request to Salesforce to enable indexing on some field and then work using that field.
Best Regards,
Vijay