Skip to main content
global Database.QueryLocator start(Database.BatchableContext bc){

return Database.getQueryLocator(SELECT id,Email,name,MailingCountry,active__C,Flag__c,Chrun_Indicator__c,Sales_Program_Type__c FROM contact where AccountId!= null and account.Active__c='yes' and ( Account.Type  like 'Customer%') and Active__c='Yes' and Email!= null and  (NOT Email  like '%cexz.com'));

    }

Unreachable statement , Unexpected token 'FROM',Expecting ';' but was: 'and'
2 answers
  1. Jan 16, 2021, 7:06 AM
    Hi Ravinder, 

    I have gone through your code. I traced the error that you have made. First, in Database.getQueryLocator we have to give any input as a string after that it converts that string into a query. So I have modified your code. please have a look.

    global class batchclass {

        global Database.QueryLocator start(Database.BatchableContext bc){

            return Database.getQueryLocator('SELECT Id,Email,name,MailingCountry,active__C,Flag__c,Chrun_Indicator__c,Sales_Program_Type__c            FROM Contact where AccountId!= null and Account.Active__c=\'Yes\' and ( Account.Type  like \'Customer%\')and Active__c=\'Yes\' and                  Email!= null and  (NOT Email  like \'%cexz.com\')');

        }

    }

    Hope this explanation will resolve your query. Mark it as the best answer if you find it helpful.

    Thanks

    Akshay
0/9000