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());
Those two methods are slightly different:
Returns the number of DML statements (such as insert, update or the database.EmptyRecycleBin method) that have
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.
- Delete acc;
See also: Limits methods in the Apex Developer’s Guide
See also: Governor Limits