Skip to main content
sandeep reddy 님이 #Apex에 질문했습니다
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

 
답변 1개
  1. 2016년 4월 27일 오전 8:24
    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){}

    }