for(PricebookEntry pbe:[Select product2Id from PricebookEntry where PriceBook2Id = :pbId]){
productIds.add(pbe.product2Id);
}
I am getting the following exception.
System.LimitException: Too many query rows: 50001 An unexpected error has occurred. Your solution provider has been notified. (Database).
It should process the records in batch why am i getting the above error?