The code provided processes all Case records in a single transaction. Since it attempts to process over 10,000 records, it exceeds the Salesforce governor limit of 50,000 DML rows per transaction, causing the transaction to fail.
Governor Limits on DML Rows (C):Salesforce enforces a governor limit of 50,000 rows for DML operations per transaction. In this case, if the SELECT query retrieves over 50,000 records, the Database.update call will hit this limit and throw a System.LimitException.
[Reference: Apex Governor Limits, Why the Try-Catch Block Fails to Handle Limits (B & D):Governor limit exceptions (System.LimitException) cannot be caught by try-catch blocks. Therefore, the exception cannot be handled, and the transaction will fail., ]
Contribute your Thoughts:
Chosen Answer:
This is a voting comment (?). You can switch to a simple comment. It is better to Upvote an existing comment if you don't have anything to add.
Submit