You need to sign in to do that
Don't have an account?
anuragsinghns
Batch Class Query
Hi I am writing a batch class to get all contacts where the EmailBouncedDate & EmailBouncedReason fields should be null.I am having a hard time saving because of the "!=" i am not bale to add the escape sequences correctly could anybody help as to where I am going wrong.
global class BouncedCaseCheck implements Database.Batchable<sObject> {
public String query;
global Database.QueryLocator start(Database.BatchableContext BC){
query='SELECT EmailBouncedDate,EmailBouncedReason,Id FROM Contact'+'WHERE EmailBouncedDate !=\''+ null+'\''+'OR EmailBouncedReason !=\''+null+'\'';
return Database.getQueryLocator(query);
}
global class BouncedCaseCheck implements Database.Batchable<sObject> {
public String query;
global Database.QueryLocator start(Database.BatchableContext BC){
query='SELECT EmailBouncedDate,EmailBouncedReason,Id FROM Contact'+'WHERE EmailBouncedDate !=\''+ null+'\''+'OR EmailBouncedReason !=\''+null+'\'';
return Database.getQueryLocator(query);
}
it saves but when I execute the batch I get the following exeption
17:47:08:059 EXCEPTION_THROWN [7]|System.QueryException: unexpected token: !=