You need to sign in to do that
Don't have an account?
Kunal Purohit 4
How to insert multiple records in Empty object using batch apex?
I am having custom object Test__c. There is no sigle record in this object. I want to insert multiple records using batch apex. Plz help.
Greetings!
You can use a custom iterator. Here is an example:
To use this, simply construct a new BatchProcessor with a list of unsaved records of any size (even millions of records), then run Database.executeBatch with the class. The only limit on the list size will be the heap. You can also use Database.Stateful if you need to record errors elsewhere, or you can catch errors and log them to a separate object used for recording this sort of information.
Edit: Note that for efficiency, this passes the list by reference, and that the code is destructive (the list will shrink to nothing as it consumes the data). If you don't want this behavior, implement an index instead.
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri