You need to sign in to do that
Don't have an account?
Ritika Singh
Record count with DML
A developer in a Salesforce org with 100 accounts executes the following code using the Developer Console:
Account myAccount = new Account(Name=’MyAccount’);
insert myAccount;
for(Integer x = 0; x < 150; x++)
{
Account newAccount = new Account(Name=’MyAccount’ + x);
try {
insert newAccount;
} catch(Exception ex) {
System.debug(ex);
}
}
insert new Account(Name='MyAccount');
How many accounts are in the org after this code is run? And why that count ?
A. 101
B. 100
C. 102
D. 252
Account myAccount = new Account(Name=’MyAccount’);
insert myAccount;
for(Integer x = 0; x < 150; x++)
{
Account newAccount = new Account(Name=’MyAccount’ + x);
try {
insert newAccount;
} catch(Exception ex) {
System.debug(ex);
}
}
insert new Account(Name='MyAccount');
How many accounts are in the org after this code is run? And why that count ?
A. 101
B. 100
C. 102
D. 252
For example when you are testing apex code you have the Test.StartTest and Test.StopTest which gives you a new transaction with new limits so in a test you could insert 150 and then put another 150 inserts between Test.StartTest and Test.StopTest.
Hope it helps, if it helps please like and mark as correct, it may help others.
All Answers
If it helps please like and mark as correct, it may help others with the same question.
Thanks for the quick help ! Just to understand this much better, when you say " it will pass 150 inserts so no account will be inserted ". We know Limit of DML= 150, but here how we can say its passing 150 inserts and left with 100 records only?
For example when you are testing apex code you have the Test.StartTest and Test.StopTest which gives you a new transaction with new limits so in a test you could insert 150 and then put another 150 inserts between Test.StartTest and Test.StopTest.
Hope it helps, if it helps please like and mark as correct, it may help others.