1

The following gives an error on runtime:

String queryString = 'select name,street_address__c from warehouse__c where' +
    'DISTANCE(location__c,GEOLOCATION('+
    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?

1 Answer 1

0

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

1
  • just a space between where and distance was missing :) Commented Apr 23, 2015 at 16:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .