+ Start a Discussion
sandeep reddy 37sandeep reddy 37 

how can we hard delete the record with out using database.emptyrecyclebin();

i need hard delete all account records  with out cheaking  recyclebin will select all and delete it
how it wii possoble which method will uses
 
JethaJetha
Anyhow you need to call  database.emptyrecyclebin() to delete your data permanently through Apex.

You can take help of below Batch Class  to delete your all account:
 
global class BatchDeletion implements Database.Batchable<sObject>, Schedulable
{   
	global void execute(SchedulableContext sc)
	{   
        BatchDeletion deleteCS = new BatchDeletion();
        ID batchprocessid = Database.executeBatch(deleteCS, 200);
    }

    
	global Database.QueryLocator start(Database.BatchableContext bc)
	{
        return Database.getQueryLocator([Select id from Account]);
    } 

    global void execute(Database.BatchableContext BC, list<sObject> scope){     
        delete scope;   
        DataBase.emptyRecycleBin(scope); 
    }

    global void finish(Database.BatchableContext BC){}
}