function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ravinder VodnalaRavinder Vodnala 

Unreachable statement , Unexpected token 'FROM',Expecting ';' but was: 'and'

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'));

    }

User-added image
SwethaSwetha (Salesforce Developers) 
HI Ravinder,
It seems to be a syntax error. Try below
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')]);
    }

When doing the SOQL queries with the QueryLocator in batch classes you need a [] around the usual ()

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Akshay Dhiman 63Akshay Dhiman 63
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