You need to sign in to do that
Don't have an account?
Aruna
Can we write more then one soql (aggregated on single object) in apex batch class start method --> urgent please can any one replay
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.
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.
i will suggest, to query all possible data in start and filter data for diffrent logic in Execute method.
Please mard answer as best if it helped anyway.
Here is an example, which may help for implementation
Please mark as best answer if it helped
So in that case I need to write 12 batch class. Please see my tables in this below link
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000kAkQIAU
I Having 6 tables each table is for current year and prior year .
I need to do grouping by rep, regional manager and RVP.
please look @ the table you will understand .
Thank you
Aruna.
As i said you can query data for this and prior year in start and you can group(With the help of collection variables) them in execute method.
but when we get year data means there will be too many rows and is it not the processing time will be by looping through all the records .
Logic implementation also will be complex right.
and if you look @ my tables i need to do grouping based on product level in one table, group by rep one table, group by region one table, group by state one table ects .
if i write one query how I am going to do all these groupings and how do I going to get current month till date ,prior year current month till date,
total prior year current month, current year till date,prior year til date, total current year, total prior year, 4 quarters of data ?
Thank you
Aruna.