You need to sign in to do that
Don't have an account?
Kevin Tullos 7
Please help me call a batch Apex Class.
Please help me write the code to execute this batch...
global class Delete_Batch implements Database.Batchable<sObject> { String query, value, field; global Delete_Batch(string s) { Query=s; //query = 'SELECT Id FROM Delete_Batch_Test__c'; } global Database.QueryLocator start(Database.BatchableContext BC) { return Database.getQueryLocator(query); } global void execute(Database.BatchableContext BC, List<sObject> scope) { Delete Scope; } global void finish(Database.BatchableContext BC) { } }I wrote something, but it could not get it to run. I don't know where to start. Could you please help me...
You can execute batch apex by using two static method in Database class
executeBatch(Instance Of class )
excecuteBatch(InstanceOf batch class ,batchsize )
So you can write code below in console and execute .
String str='SELECT id FROM Account ';
Delete_Batch bdt=new Delete_Batch(str);
Database.executeBatch(bdt);
or
Database.executeBatch(bdt,100);
All Answers
You can execute batch apex by using two static method in Database class
executeBatch(Instance Of class )
excecuteBatch(InstanceOf batch class ,batchsize )
So you can write code below in console and execute .
String str='SELECT id FROM Account ';
Delete_Batch bdt=new Delete_Batch(str);
Database.executeBatch(bdt);
or
Database.executeBatch(bdt,100);
for other object you need to modify the query .and add your object name inplace of Account .If you need any condition you can add in your query .
Please try below code:-
String query = 'SELECT Id FROM Delete_Batch_Test__c'; // Please add your query here.
Database.executeBatch( new Delete_Batch( query ) );
Please exceute above code in developer console. Please let us know if this will helo you.
Thanks
Amit Chaudhary
String query = 'SELECT Id FROM <sobject>'; // Please add your query here.
Database.executeBatch( new Delete_Batch( query ) );