Limits.getDMLStatements() / Limits.getLimitDMLStatements()

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());

Answer

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

Attribution
Source : Link , Question Author : Nick Kahn , Answer Author : Bahman.A

Leave a Comment