You need to sign in to do that
Don't have an account?
how to return the query in Batch apex
Hi guys,
can u help me in the query.
-----Batch Class---------
global class Del_leads implements Database.Batchable<sobject>
{
date d=system.today();
integer i=7;
date z=d-i;
global Database.QueryLocator start(Database.BatchableContext BC)
{
return Database.getQueryLocator('select id,name from lead where createddate<=\'z\' and date_opened__c=null');
}
global void execute(Database.BatchableContext BC,List<Lead> Lds)
{
delete Lds;
}
global void finish(Database.BatchableContext BC)
{
System.debug(LoggingLevel.WARN,'Deleting leads Finished');
}
}
-----------Schedule class-------------------------------
global class bulkdelleads Implements Schedulable{
global void Execute(SchedulableContext SC){
Del_leads ld=new Del_leads();
database.executebatch(ld);
}
}
Thanks
Anil.B
Try this...
global String Query;
date d=system.today();
integer i=7;
date z=d-i;
global Database.QueryLocator start(Database.BatchableContext BC)
{
query= 'select id,name from lead where createddate<= :z and date_opened__c=null';
return Database.getQueryLocator(query);
}