0
List<Contact> c = [SELECT ID FROM Contact WHERE AccountId !='00190000016ozwL']; 

System.debug(c.size()); 

Database.SaveResult[] srList = Database.delete(c, false);

This is anonymous apex that I am trying to execute.

I am getting the following error while executing.

Illegal assignment from LIST&lt;Database.DeleteResult&gt; to LIST&lt;Database.SaveResult&gt;

Not sure why am I getting this error because "c" is a collection only.

Can someone let me know ?

5

Database.delete returns Database.deleteResult. Database.saveResult is returned for insert and update operations.

So you should change you code to:

Database.deleteResult[] srList = Database.delete(c, false);

You can find more info here: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_database_deleteresult.htm

3

I don't think you can do deletes with the SaveResult class

The result of an insert or update DML operation returned by a Database method.

You should be using the DeleteResult classs

Represents the result of a delete DML operation returned by the Database.delete method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.