function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Issue with Deleting Records

I've had an issue with deleting records, which I thought was caused by the size of the batches. But when I run this in the System Log:


delete [Select Id From CustomObject__c Limit 1];


I get this error:


EXCEPTION_THROWN|[1]|System.DmlException: Delete failed. First exception on row 0 with id xxxxxxxxxxxxxxxxxx; first error: UNKNOWN_EXCEPTION, Operation affected too many rows: []


How is it possible that one row is too many? Is there a daily limit for DML rows?



This can happen for a couple of reasons:


(1) There is a trigger or triggers that is deleting other records

(2) CustomObject__c is the master in a master-detail relationship, and there are a large amount of detail records that would be deleted as part of this. 


There's a limit of 10,000 records affected by DML in a single transaction.


sorry, I should have specified what I tried before coming here.


the instance I'm working also has no triggers. also, there are a number of lookup fields pointing to CustomObject__c, but no actual records that aren't null for those fields, and there are no master-detail fields pointing to it. I was thinking a cascade may have been the cause, but once I saw there was nothing that would be deleted as a result, I eliminated that as a possible cause.


I was thinking that it may be a daily limit since I am working with a Professional Edition instance (API-enabled), and we are using the API to move a lot of data over.


I did find a way to get around this (removing the object, didn't need to persist the data), although that's not exactly a resolution. more of a work-around.


thanks for your help.


 I do want to cascade delete, but how can I workaround the 10K limit? Thank you