About this question
I have created formula field named "Second Audit Required" as shown below :
IF(And(AND(Text(Status__c)='Closed',TEXT(ServiceStep__c)='Treatment',Order__r.Account_Name__r.Account_Types__r.Name='Individual'), AND(Sequence_No__c=1),And(Text(Service_Audit_Type__c) !='Second Audit')), IF(Order_Service_Area__r.Service_Plan__r.SP_Code__c<>Null, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0875",TODAY()- Delivery_Date__c>1460 ),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0573",TODAY()-Delivery_Date__c>180),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0726",TODAY()-Delivery_Date__c>180),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0070",TODAY()-Delivery_Date__c>365),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0634",TODAY()-Delivery_Date__c>730),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0577",TODAY()-Delivery_Date__c>180),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0072",TODAY()-Delivery_Date__c>180),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0469",TODAY()-Delivery_Date__c>1460),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0724",TODAY()-Delivery_Date__c>365),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0438",TODAY()-Delivery_Date__c>180),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0725",TODAY()-Delivery_Date__c>730),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0584",TODAY()-Delivery_Date__c>730),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0723",TODAY()-Delivery_Date__c>180),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0729",TODAY()-Delivery_Date__c>1460),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0067",TODAY()-Delivery_Date__c>180),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0443",TODAY()-Delivery_Date__c>1460),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0627",TODAY()-Delivery_Date__c>180),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0727",TODAY()-Delivery_Date__c>180),True, IF(AND(Order_Service_Area__r.Service_Plan__r.SP_Code__c="SP0728",TODAY()-Delivery_Date__c>365),True, False))))))))))))))))))),False),False)When I am doing a query in batch class and using this field to retrieve and filter I am getting an error as below : First error: common.exception.SfdcSqlException: ORA-00920: invalid relational operator
Query is :
[Select id,name from ObjectNAME__c where Second_Audit_Required__c= true and Second_Audit_Required__c != null];