I'm trying to delete certain records from the recycle bin. I am querying the Account records like as:

Map<Id,Account>accMap = new Map<Id,Account>([Select id.name from Account where Type='xyz value' ALL ROWS]);
List<ID> accIds = new List<Id>(accmap.keyset());// Getting correct Ids 
//my account records are successfully deleted from recycle bin

However if i do the same query again then it again showing the same account records.

Can anyone help me why these records are coming out by SOQL but has already been removed from recycle bin.

  • Can you confirm that there is a delete somewhere in your logic? Assuming there is, the first thing to check would be the results returned by the call that can include error messages as the signature is "Database.EmptyRecycleBinResult[] emptyRecycleBin(ID [] recordIds)".
    – Keith C
    Commented Mar 21, 2014 at 12:47
  • Actually records have already been deleted from Objects and that's why present in recycle bin. Now I wanted to remove these records from recycle bin also.But as Salesforce do not provide any such UI to remove some specific records from recycle bin i prefer to use Database.emptyRecycleBin(Id[]).
    – userRg
    Commented Mar 21, 2014 at 12:53
  • 1
    Fine, just that your posted code isn't clear as "ALL ROWS" includes non-deleted too. But looks like you have a good answer from @PepeFloyd; pity the API docs don't mention that.
    – Keith C
    Commented Mar 21, 2014 at 13:06
  • ALL ROWS looks at soft deleted rows, it is not specifically looking in the recycle bin. You can have soft deleted data that exists, but is not in the recycle bin.
    – superfell
    Commented Mar 21, 2014 at 14:57

1 Answer 1


This is because the records have not been hard deleted from the recycle bin. Salesforce runs a process on a scheduled basis that physically deletes records that have been deleted from the recycle bin, if that process has not run yet, you will still see the records there.

A fuller description of the behavior of emptyRecycleBin can be found here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .