0

I'm going to write a daily scheduled apex class. I have a couple of questions about the governor limit:

1)Example:

> Account acct = new Account(name='test account');
> 
>         insert acct;
> 
>          
>         Contact[] contactsToCreate = new Contact[]{};
> 
>         for(Integer x=0; x<1000;x++){
> 
>             Contact ct = new Contact(AccountId=acct.Id,lastname='test');
> 
>             contactsToCreate.add(ct);
> 
>         }
> 
> 
>         insert contactsToCreate;

So i will have just 1DML for 1000 records (salesforce limit is 150 DML instructions) which is the size limit for a list(like contactsToCreate) for an insert () DML statement?

2)for (List<Account> accts : [select name from Account])

is there some limit about the number of record that i can manage with a for loop like the above?

Thanks in advantage for any advice. BR

3
  1. The limit is 10,000

  2. The for loop batches the results, so you are really limited by the max return of the SOQL query which is 50,000

Hope this helps

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

https://na6.salesforce.com/help/doc/en/salesforce_app_limits_cheatsheet.pdf

http://wiki.developerforce.com/page/Apex_Code_Best_Practices

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.