You need to sign in to do that
Don't have an account?
Sylvio Avilla
Bulkfy Sample Code
Hello,
I would like some help to bulkify the code bellow:
I would like some help to bulkify the code bellow:
for (Trip__c trip : trigger.new ) { List<Trip__c> myTrips = [Select ID from Trip__c WHERE day__c =:trip.Day__c and driver__c =:trip.driver__c]; .... rest of the code .... }Thanks
The problem is that my SOQL is inside the Loop... can you explain in more details how can I move it outside?
Thanks
set<string> setdriverDayKey=new set<string>();
string strKey;
for (Trip__c trip : trigger.new )
{
strKey=trip.Day__c + '' + trip.driver__c;
setdriverDayKey.add(strKey)
}
List<Trip__c> myTrips = [Select ID from Trip__c WHERE Key__c in:setdriverDayKey];