Skip to main content
Hi there ,

I am having a requirement  where I need to pass  multiple  aggregated soqls(6) on single object with different where clause  to apex batch start method and run the logic in execute method and schedule that batch class to run nightly base.

as for as I know we can pass only one soql  to start method

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

                  return Database.getQueryLocator(Query);

}

But what I want is 

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

                  Database.getQueryLocator(Query1);

                  Database.getQueryLocator(Query2);

                 Database.getQueryLocator(Query3);

                 Database.getQueryLocator(Query4);

                 Database.getQueryLocator(Query5);

}

You may say why don't you write single batch each query . I different queries(50) with different where clause .

If I write at least multiple queries in one batch class I can decrease number batch scheduled class.

 
6 answers
0/9000