function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Batc updating/insert massive records in apex?

Can anyone give an example how i would batch update loads of records in apex?

for example say i have a query that returns like 10k accounts and i want to update a field on all those accounts how would i update those accounts in apex code?

Well, according to the logic of your program, you can combine an scontrol + Apex webservice in order to update (max) 1000 records at once and from the scontrol manage the invocation of the WS until no more data be found.

I suggest to use an autonumeric field that will be useful to mark after every iteration which was the last updated record and then to start again from the next record.