schedulable class example in salesforce
global class SAPOrdersDeleteScheduler implements Schedulable {
global void execute(SchedulableContext sc){
List cldOrders = [select Id from SAPOrder__c where Status__c ='Closed'];
List cldOrderItems=[select Id from SAP_Order_Item__c where SAPOrder__c in:cldOrders];
if(!cldOrderItems.isEmpty())
{
delete cldOrderItems;
}
if(!cldOrders.isEmpty())
{
delete cldOrders;
}
}
}