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
SuperdomeSuperdome 

[Apex Design Pattern] Too many dml rows:10001

Like to do a update with more than 2,000,000 records in the developer console.
 
Is the pattern workable to do the task ?
 
Boolean onOff = true;
while(onOff){
    onOff = asyncApex.doUpdate();
}
 
----------
global class asyncApex {
 
  @future 
  public static Boolean doUpdate() {
       List<Object> recs = [ select id,  name from Object LIMIT 10000];
       List<Object> rUpdate = new List<Object>();
       for(Object o: recs){
            Object t = new Object();
            ....
            rUpdate.add(t);
        }
        update rUpdate;
        if(recs.size()==0) return false; else return true;
  }
}
Best Answer chosen by Admin (Salesforce Developers) 
Dhaval PanchalDhaval Panchal
You can use batch apex.