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
patelankurbpatelankurb 

Batch Apex : Too many DML rows: 10001 error

Hi Guys,

 

I have two objects Target List and Selling Area. Also have Target List Member object as junction of both. User can create target list and add selling area based on some search criteria. I am storing that SOQL in query field of Target List. Overnight batch to run through all target list get the query and iterate over query result and insert Target List Member records. But Batch class gives me Too Many DML rows error while insertion.

 

I am testing this with 4 target lists Each of them have separate query. These quries return 2764 records of selling area. Means 2764*4 target list members.  Now requirement is one target list can have up to 50K-80K selling area, so setting scope to 1 won't solve my problem. Any suggestion or workaround?

 

Thanks,

Ankur

 

ca_peterson_oldca_peterson_old

Are you inserting the records inside of your finish() method? That sounds like your problem: the finish() method has the same govenor limits as a single batch. Move the insert statements inside of the execute() method and it will insert batches of 200 at a time as the batches run, rather than saving them all for the end.

patelankurbpatelankurb

Nope. My insert statement is in execute method. I am inserting records in juction object and my batch query is on Target List.

S__S__

Hi Ankur,

 

Do you find a  work around yet? I am facing a similar issue and looking for any ideas.

 

Thanks,

nagalakshminagalakshmi

Hi,

 

I am also facing same problem. Are got any solution for this. Please help me out.

 

Thanks,

Lakshmi