I keep getting the error:
System.QueryException: expecting a colon, found 'setids'
Why do I get this error? How can I fix it?
public Database.QueryLocator start(Database.BatchableContext context) {
Set<Id> setids = new Set<Id>();
for(Task t : [SELECT WhatId FROM Task WHERE Is_Precall__c = true AND Is_Created_By_Batch__c = true AND CreatedDate = TODAY]){
setids.add(t.WhatId);
}
String q = 'SELECT Id, Route_Lookup__c, Next_Delivery_Date__c,';
q += ' Market_Center_Lookup__c,';
q += ' (SELECT Id FROM Orders__r WHERE Status = \'Pending\')';
q += ' FROM ServicePoint__c WHERE Type__c = \'Active\'';
q += ' AND Is_Batch_Exec_Date__c = true';
q += ' AND Is_Precall_Customer__c = true';
q += ' AND Id NOT IN setids' ;
return Database.getQueryLocator(q);
}