We are using Jitterbit to query records from Salesforce, but we are running into an issue. In the query condition statement I am comparing two fields from the Salesforce table. When I go to test the query, it gives me the error "Bind variables only allowed in Apex Code [MALFORMED QUERY]".
Here is an example of the query:
SELECT Id FROM Price_Agreement_Item__c WHERE Approved_Date__c > Last_Upload_Date__c
The fields Approved_Date__c
and Last_Upload_Date__c
are both contained in Salesforce table Price_Agreement_Item__c
. How does one create a SOQL statement that conditions the select statement comparing two fields in the table?
Any help is appreciated.
Thank you in advance.
SOQL doesn't currently support direct field to field comparison in WHERE clauses. From Field to field comparison in WHERE clause of SOQL
You could create a formula field of type Checkbox to return a boolean:
Then rewrite your query with your WHERE clause like:
Be careful about how many rows this will need to scan over. It can't use an index, so will result in a full table scan. If the number of rows gets too large you could get other errors.
Incidentally, the Salesforce Stack Exchange is a great place to ask Salesforce specific questions. This answer references a question from there answered by Jesse Altman with comments by Keith C and sfdcfox.