• anusha reddy 158
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
I've two objects(Obj1 & Obj2), i will have to fetch the data in obj1. And based on the fields data in obj1, i've to query the data in Obj2.
global Class batchapex1 implements Database.Batchable<sObject>{
    Public Set<String> passeddata{get; set;}
    global Database.QueryLocator start(Database.BatchableContext BC){
        return Database.getQueryLocator([Select fld1,fld2,fld3 from Obj1 where fld1 in: passeddata]);
    }
    global void execute(Database.BatchableContext BC, List<Obj1> Obj1List){
        
    }
    global void finish(Database.BatchableContext BC){
        
    }
}
But here based on the Obj1 query data, i'will have to fetch the obj2 data like below
Set<String> obj1data= new Set<String>();
for(Objj1 i:Obj1List){
    obj1data.add(i.fld1)
}
if(obj1data.size() > 0){
    Obj2List = [Select fld1,fld2,fld3 from Obj2 where fld1 in: obj1data];
}
//some calculations happen comparing the obj1 data & obj2 data and finally update obj1 data

The concern here is two objects returns large data around 1lakh records each. i would like to have both the queries are returned through querylocator as many no. of records(50M) can be queried through query locator. Please advise