//DML 151
Critical Limit Breach

System.LimitException:
Too many DML statements: 151

System.LimitException: Too many DML statements: 151

You thought bulkifying was optional. Then you hit 151 DML statements and your trigger crashes mid-transaction. Partial rollback chaos. Records in an inconsistent state. Users screaming because their data is corrupted.

8,500 developers search for this error every month. The fix is simple—bulkify your DML—but the consequences of not doing it are catastrophic.

Jataka catches DML 151 in real-time
0:58
Watch: Developer writes DML in loop → Jataka blocks PRLoom Recording

The Limit: 150 DML statements per transaction

150

Maximum DML operations (insert/update/delete) per transaction

151

The statement that corrupts your data with partial rollback

3 hrs

Average time to recover from partial data corruption

Unlike SOQL queries, DML statements modify data. When you hit the limit mid-transaction, Salesforce rolls back everything. But if you have mixed DML or external system integrations, you might end up with orphaned records, inconsistent state, or data that can't be recovered.

The Bad Code

This code looks harmless. Update each opportunity as you process it. What could go wrong?

OpportunityTriggerHandler.cls❌ Anti-Pattern
// ❌ BAD: DML inside a for loop
// Each iteration runs a separate DML operation

public void updateOpportunities(List<Opportunity> opps) {
    for (Opportunity opp : opps) {
        // DML operation inside the loop!
        opp.StageName = 'Closed Won';
        opp.CloseDate = Date.today();
        update opp; // 1 DML per iteration
    }
    // With 200 opportunities = 200 DML statements
    // Limit is 150. Crash at 151.
}

Jataka Report Card

Jataka executes this code in an isolated Sandbox and catches the DML breach before it touches Production.

PR #312 Blocked
5 minutes ago

DML Statements

187/150

DML Rows

187/10,000

SOQL Queries

12/100

CPU Time

1,247ms/10,000ms

DML Limit Breach Detected

Transaction executed 187 DML statements. Limit is 150. Found DML inside for loop at line 11.

The Fix

Collect all changes in memory. Execute one DML statement at the end.

OpportunityTriggerHandler.cls✓ Bulkified
// ✅ GOOD: Bulkified DML operations
// Single DML statement for all records

public void updateOpportunities(List<Opportunity> opps) {
    // Update all records in memory
    for (Opportunity opp : opps) {
        opp.StageName = 'Closed Won';
        opp.CloseDate = Date.today();
    }
    
    // Single DML operation
    update opps;
    // 1 DML total, regardless of record count
}

Result: 1 DML statement instead of 187. All records update atomically. No partial rollback. No data corruption.

Related Anti-Patterns

Prevent data corruption

Jataka catches DML 151
before the merge.

Book a demo and watch Jataka block this exact error in real-time. Your data stays consistent.