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
aniruddha maitianiruddha maiti 

Understanding DML Errors

I am trying to understand the DML and Query Record Governor limits.
Code:
list<account> a = new list<account>();
    for(integer i=0;i<9999;i++)    {
        a.add(new account(Name =('ani '+(i*4).format()),AccountNumber=('anii'+(i*8).format())));    }
      database.insert(a); 
TRying this it throws-> QUery over 50,000 records..
If I try inserting 1000 records and take the insert(a) inside the loop, DML error limit 150. I can understand that but please help me understnad the query record error. I am on Developer free edition and have only 10 records in Account object.

 
James LoghryJames Loghry
Are you querying any records in the same class, and looping in a similar manner?  Or perhaps you have a trigger on the Account object that kicks off a query?