You need to sign in to do that
Don't have an account?
Divya Goel
System.Exception: Too many DML rows: 101
Hi
I have to update more then 100 records in my update call but the limit of the trigger is just to update only 100 records in a trigger. Please let me know how i can update more then 100 records in my trigger.
Thanks
Divya Prakash Goel
I assume that the solution would be to test if your list object has more than 100 rows, and if it does break the primary list into sub lists then update the sub list... .something like:
if(fullList.size() > 100){
List<obj> subList = new List<obj>();
for(obj record : fullList){
subList.add(record);
if(subList.size()==99){
update subList;
subList.clear();
}
}
if(subList.size() > 0){
udpate subList;
}
}else{
update fullList;
}
All Answers
Help please!?
Thanks in advance.
I assume that the solution would be to test if your list object has more than 100 rows, and if it does break the primary list into sub lists then update the sub list... .something like:
if(fullList.size() > 100){
List<obj> subList = new List<obj>();
for(obj record : fullList){
subList.add(record);
if(subList.size()==99){
update subList;
subList.clear();
}
}
if(subList.size() > 0){
udpate subList;
}
}else{
update fullList;
}
This is not the correct solution.
100 is the limit of DML records that can be process for each record that fires the trigger.
Breaking the list which is greater than 100 records into sublists will still hit the limits.
Example: The first sublist's DML will be fine as it is under 100 records but the second will fail as it goes over 100 records for the record that causes the trigger to fire! The limt is not refreshed after the first DML.
These limits scale with trigger batch size.
1 record to hit trigger, 100 DML records can be processed
2 records to hit trigger, 200 DML records can be processed
3 records to hit trigger, 300 DML records can be processed
etc, etc
I have resolved this problem by limiting the amount of records being returned by my SOQL query but another solution could be to look into Batch Apex. You can find more information about this in the Apex Code Developer's Guide.
Good luck!
Hi,
How I can overcome this issue in Batch Apex? Any suggesstion.
Thanks.
Thanks