1

I am facing an issue with the querylocator line here. My code snippet as below.

global Database.QueryLocator start(Database.BatchableContext BC){
      query = 'select Id,(select Name from Call2_vod__r where Signature_Date_vod__c !=Null and Account_vod__c not in :existMap.keySet() limit 1) from Account';
      return Database.getQueryLocator(query);}

Error: |FATAL_ERROR|System.QueryException: expecting a right parentheses, found '(' Class.Account_chk_batch.start: line 5, column 1

Line5 is return statement here.Can someone please help?

  • Not sure whether '(' mark need to be escaped or not – highfive Sep 3 '14 at 9:14
2

Interestingly it is this code that doesn't run inside developer console. Try a slight change and see if this works for you.

global Database.QueryLocator start(Database.BatchableContext BC){
set<string> keys = existMap.keySet();
      query = 'select Id,(select Name from Call2_vod__r where Signature_Date_vod__c !=Null and Account_vod__c not in :keys limit 1) from Account';
      return Database.getQueryLocator(query);}

I've just replaced the existMap.keySet() in the query to a set with the keys in. Looks like a problem with the query with the () inside.

| improve this answer | |
  • 1
    See the "simple bind variables" mention in the Dynamic SOQL documentation for more information on this. – Keith C Sep 3 '14 at 9:45
  • Thanks Richard! It's working. But it is taking long time to complete batch run. Will let you know about this.:) – Testing_SFDC Sep 3 '14 at 10:18
  • I am sorry Richard. It is showing below error. – Testing_SFDC Sep 3 '14 at 10:18
  • Error:First error: Apex CPU time limit exceeded – Testing_SFDC Sep 3 '14 at 10:19
  • You'll probably need a where clause on your main select (from Account). Try the query in developer console and see what's returned. – Richard Durrant Sep 3 '14 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.