Syntax:
global class class_Name Implements Database.Batchable <sObject> {
global Database.queryLocator start( Database.BatchableContext bc ) {
String strSOQL = 'SELECT Id FROM sObject';
return Database.getQueryLocator( strSOQL );
}
global void execute( Database.BatchableContext bc, List < sObject > scope ) {
}
global void finish( Database.BatchableContext bc ) {
}
}
To execute:
Class_Name obj = new Class_Name();
Database.executeBatch( obj );
To schedule:
global class Scheduleclass_Name Implements Schedulable {
global void execute(SchedulableContext sc ) {
Class_Name obj = new Class_Name();
Database.executeBatch( obj );
}
}