You need to sign in to do that
Don't have an account?
Prakash Devloper
Heere is the code.
public class batchApex implements Database.Batchable<sobject> {
public static List<account> aclist = new List<Account>();
public static Database.QueryLocator start(Database.BatchableContext bc){
return Database.getQueryLocator('select Name From Account');
}
public static void execute(Database.BatchableContext bc,List<Account> accList){
for(integer i=0;i<50002;i++){
Account acc = new Account();
acc.Name='Test'+i;
acc.AccountNumber='1234567';
aclist.add(acc);
}
insert aclist;
}
public static void finish(Database.BatchableContext bc){
}
}
batchApex obj = new batchApex();
Database.executeBatch(obj,2000);
It show error that Too many DML rows: 10001.
Batch apex can process upto 5million record .Why it showin error.
And
If the first transaction succeeds but the second fails, the database updates made in the first transaction are not rolled back. How it works ?
Too many DML rows: 10001 DML error working with Bathapex
Heere is the code.
public class batchApex implements Database.Batchable<sobject> {
public static List<account> aclist = new List<Account>();
public static Database.QueryLocator start(Database.BatchableContext bc){
return Database.getQueryLocator('select Name From Account');
}
public static void execute(Database.BatchableContext bc,List<Account> accList){
for(integer i=0;i<50002;i++){
Account acc = new Account();
acc.Name='Test'+i;
acc.AccountNumber='1234567';
aclist.add(acc);
}
insert aclist;
}
public static void finish(Database.BatchableContext bc){
}
}
batchApex obj = new batchApex();
Database.executeBatch(obj,2000);
It show error that Too many DML rows: 10001.
Batch apex can process upto 5million record .Why it showin error.
And
If the first transaction succeeds but the second fails, the database updates made in the first transaction are not rolled back. How it works ?
As stated in government Limit documentation ( https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm )
Total number of records retrieved by SOQL queries: 50,0000
Total number of records retrieved by Database.getQueryLocator: 10,000
SOQL :
DML:
Here you're trying to insert aclist (which contains how many accounts?)
If its more than 10K government limit won't allow. That's why error. You have met DML limit not SOQL limit.
Try inserting less that 10k records. It won't give error.