Skip to main content
* How to overcome of if i want to use more than 150 DML statements in apex . as per governer limit we cant use than 150 DML , to overcome this what we need to do?

 
4 answers
  1. Sep 16, 2015, 4:40 PM
    Hi Mahantesh,

    It's not possible to use more than 150 DML statements in a single apex transaction.

    If you need to insert/update/delete many records you can do so by calling a DML statement on a list.

    For example, to insert 150 new accounts you could do this.

     

    // create 150 accounts

    List<Account> accounts = new List<Account>();

    for(Integer i = 0; i < 150; i++)

    {

    Account account = new Account(Name = 'Test Account');

    accounts.add(account);

    }

    insert accounts; // insert the entire list - this only consumes 1 DML statement.

    Hope that helps,

    Clint
0/9000