You need to sign in to do that
Don't have an account?
cchang
Apex Batch: Scope of Database.QueryLocator returned ignored the where statement in the query
I have a batch job defined below as the scope.
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator([select id, DUNS_Number__c, Parent_DUNS__c, ParentId from Account where Parent_DUNS__c != null]);
}
But from the debug log, I saw the scope is returned as: select id, DUNS_Number__c, Parent_DUNS__c, ParentId from Account
The where statement is ignored completely. So there are much more records returned.
I do not know what went wrong.
Does your query run fine in the query editor in the developer console ?
I'm seeing that on other code execution but I doesn't really affect the number of records retrieved.
Does it affect your returned value?
The APEX 26.0 doc for getQueryLocator() says the argument needs to be a string, not a [..] expression. Try that
I think you should create a support ticket with Salesforce. I'm currently working on batch apex and although I'm seeing that the query does not include the where condition when I debug, the number of records returned is correct so there might be some internal issue for your Org.
Also I have been using expression rather than string specially on old API version and its working for me.
I am also facing this same problem and the rows returned are incorrect in my case. This the query which I am passing as a string:
String query='Select Id, CreatedDate
From InventoryTransaction__c
where Transaction_Type__c Like '%Shipments%' and CreatedDate >= 2012-11-06T12:00:00z
order by CreatedDate Asc limit 10000'';
ApexPages.StandardSetController ctl=new ApexPages.StandardSetController(Database.getQueryLocator(query));
Is this a Salesforce bug and is there a workaround?