Skip to main content
Raj Ruprai preguntó en #Apex
Hi,

I have an optimization and batch apex question. We will have to make HTTP callout from a batch class and the query that we will be passing in is below. In terms what is better for optimization and what would be easier, would the following be recommended? Is there another way to do this?

 

//query

String query = 'Select Name, Id, OwnerId From Account Where ID IN: (Select AccountId From AccountHistory)';

 

//batch class

SendAccounts sender = new SendAccounts(query)

Database.executeBatch(sender);

//batch class definition

global class SendAccounts implements Database.Batchable<sObject>, Database.AllowCallouts{

global final String Query;

global SendAccounts (String qry){

Query=qry;

}

global Database.QueryLocator start(Database.BatchableContext BC){

return Database.getQueryLocator(query);

}

global void execute(Database.BatchableContext BC, List<sObject> scope){

//perform logic

//make 1 http callout

}

global void finish(Database.BatchableContext BC){

}

}

 
1 respuesta
  1. 3 jul 2017, 19:12
    Hi,

    select Accountid,   account.name,   account.ownerid   from AccountHistory

    There is a trick to know if you want that works with the workbench using a new line for each field.

    Otherwise, the workbench rejects with an error but it is clearly possible.

    Hi,select Accountid, , account.ownerid from AccountHistoryThere is a trick to know if you want that works with the workbench using a new line for each field.

    Best regards

    Alain
0/9000