11

Can anybody explain me the diff. and why I'm getting the following results

 Limits.getDMLStatements() = 2 and
 Limits.getLimitDMLStatements() =  150

List<Account> acc = [SELECT Id FROM Account LIMIT 10];
Delete acc;
Database.emptyRecycleBin(acc);

system.debug(Limits.getDMLStatements() +', '+ Limits.getLimitDMLStatements());

1 Answer 1

20

Those two methods are slightly different:

getDMLStatements() Returns the number of DML statements (such as insert, update or the database.EmptyRecycleBin method) that have been called.

getLimitDMLStatements() Returns the total number of DML statements or the database.EmptyRecycleBin methods that can be called.

One tells you how many DML statements you've made, the other tells you the most you're allowed to make.

In your case, you're making two calls.

  1. Delete acc;
  2. Database.emptyRecycleBin(acc);

See also: Limits methods in the Apex Developer's Guide

See also: Governor Limits

3
  • 150 DML statement is standard allowed to make?
    – Nick
    Nov 29, 2015 at 1:21
  • 2
    yes in a single transaction 150 DML statement allowed
    – Ratan Paul
    Nov 29, 2015 at 1:27
  • 1
    If this answers your question, don't forget to mark it as the correct answer.
    – Nick C
    Nov 29, 2015 at 3:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .