You need to sign in to do that
Don't have an account?
Ashutosh
How can I know the number of records retrieved
Hi,
I want to process around 10,000 records using Apex. While querying on object I have limited to 1000 records at a time but I just want to know, "How can I get only those records, which has not been processed/ queried."? So that I can process 1000 records every time in loop.
user[] u = [SELECT Id FROM user];
Integer noOfRecords = u.size()
Hi,
The trick here is to nest your 'select' within your for-loop, something like:
for (Contact c : [SELECT Name FROM Contact]) { // Do work on Contact c}
This works similar to the 'Query More' option in Apex Explorer, where it will batch the select until it has retrieved them all...
But remember, if you are bulk-processing collections of objects, you can only store 1000 objects in an array, so you may need to manually control batching of your logic, e.g.
List<Contact> contactList = new List<Contact>();for (Contact c : [SELECT Name FROM Contact]) { contactList.add(c); if (contactList.size() > 999) { // Do work on list of contacts DoWork(contactList); // Empty the list - cannot contain > 1000 objects contactList.clear(); }}// Process any remaining contacts in the list...DoWork(contactList);
HTH,
Ian Randall