Yes, you can update them in batches of...well, I've forgotten the limit, but I believe it's 100. It's in the API developer's guide whatever that limit is.
Just make an array of SObjects with the desired changes, ensure that array has less than the maximum number (which I hypothesize is 100), and pass that array to the update call.
To handle a large number of records, use the for-list language construct-- this allows you to iterate using "queryMore" (internally) to efficiently handle a large number of records (governor limits apply). For example:
This queries 200 records at a time, updates all 200 in-memory records, and then writes the updates back to Salesforce (don't do this unless you really want to blank all your industry values). Note that there would be an upper cap of how many records you could update (Limits.getLimitDMLRows() records or Limits.getLimitDMLStatements()*200, whichever is lower, but can't exceed 20,000).
If your query goes above the governor limits, you'll simply get an error and all the changes will roll back. If you need to upate more than what's allowed, you would need to then change the function to a web services call and use the AJAX toolkit in that case... or use the @future annotation so you can run the call asynchroniously, which has a much higher governor limit. If you need more than what an async call can do, then you definately should consider using the AJAX toolkit. Generally, if you're needing to use a large number of records at once, you're probably designing whatever it is you're trying to do wrong.
Message Edited by werewolf on 06-27-2008 02:08 PM
Message Edited by sfdcfox on 06-28-2008 07:22 PM
Account[] accList = [SELECT Id, Name FROM Account];
if there are more than 200 how i do batch them for update
update accList; ??
Message Edited by lodoss118 on 06-30-2008 08:27 AM
To handle a large number of records, use the for-list language construct-- this allows you to iterate using "queryMore" (internally) to efficiently handle a large number of records (governor limits apply). For example:
This queries 200 records at a time, updates all 200 in-memory records, and then writes the updates back to Salesforce (don't do this unless you really want to blank all your industry values). Note that there would be an upper cap of how many records you could update (Limits.getLimitDMLRows() records or Limits.getLimitDMLStatements()*200, whichever is lower, but can't exceed 20,000).