The following gives an error on runtime:

String queryString = 'select name,street_address__c from warehouse__c where' +
    lat + ',' + lon+
    ' ),\'mi\') <'+distance;
results = Database.Query(queryString);

The error message says

unexpeced token: (

The error goes away if the comment the second line. What is the issue?


Nevermind, I found the error. Corrected it to:

String queryString = 'Select Id, name ' + 'from warehouse__c ' + 'where distance(location__c, GEOLOCATION('+lat+','+lon+'), \'mi\') < 20 ' + 'limit 10';

  • just a space between where and distance was missing :) – Rajiv Bhatt Apr 23 '15 at 16:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.