function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
JimmyMacJimmyMac 

How To Call an Apex Batch Class

Hi,

 

I am trying to execute the following Batch Apex Class from the Developers Console:

Id batjobId = Database.execute(new BatchLoadDaily('fm1000'),200);

 

 

 

Below is my Apex Class:

 

global class BatchLoadDaily implements Database.Batchable<sObject> {
  global final String bdId;
 
 
  global BatchLoadDaily(String bdId) {
    this.bdId = bdId;
    
  }
 
  global Database.QueryLocator start(Database.BatchableContext bc) {
    return Database.getQueryLocator('SELECT payout__Account_Desc__c, payout__Account_Opening__c, payout__Account_Type__c, payout__Albridge_ID__c, payout__Asset_Fund_Name__c, payout__Asset_Type__c, payout__BD_Id__c, payout__Cirrus_Source__c, CreatedById, CreatedDate, payout__CumDisc__c, payout__Cusip__c, payout__Dealer__c, payout__DealerBranch__c, IsDeleted, payout__Financial_Account_Number__c, payout__FirstName__c, payout__IRS_Code__c, Name, LastModifiedById, LastModifiedDate, payout__LastName__c, payout__Last_Price__c, payout__Last_Price_Update__c, payout__Market_Value__c, payout__MiddleName__c, payout__Num_Of_Shares__c, OwnerId, payout__Payout_Date__c, payout__PersonMailingCity__c, payout__PersonMailingStateProv__c, payout__PersonMailingStreet__c, payout__PersonMailingZip__c, payout__PersonOtherPhone__c, payout__Phone__c, payout__Plan_Status_Code__c, ConnectionReceivedId, Id, payout__Registration_Line_1__c, payout__Registration_Line_2__c, payout__Registration_Line_3__c, payout__Registration_Line_4__c, payout__SSN__c, payout__SSN_Financial_Account__c, ConnectionSentId, payout__Shares__c, payout__Sponsor_Name__c, payout__Symbol__c, SystemModstamp, payout__Systematic_Plan_Type__c, payout__Tax_Status__c, payout__UniqueId__c, payout__Valuation_Date__c  FROM payout__ImportStaging__c where payout__BD_Id__c = \'' + bdId + '\'');
  }
 
  global void execute(Database.BatchableContext bc, List<payout__ImportStaging__c> scope) {
   
       boolean upsertCertainFields;
       boolean noUpsertHldOrMVH;
       string recType;

 

I am getting an error saying it is an incorrect signature..... What am I doing wrong? Thanks to all.

Rahul_sgRahul_sg
BatchLoadDaily bat = new BatchLoadDaily ();
Database.executeBatch(bat, 200);
JimmyMacJimmyMac

That was almost it... Needed to also pass in a parameter.

 

BatchLoadDaily bat = new BatchLoadDaily('fm10000');
Database.executeBatch(bat, 200);

 

Thanks.