System.QueryException: unexpected token: 's'

When you face System.QueryException: unexpected token: 's'  issue, use String.escapeSingleQuotes() method to avoid that.

Sample SOQL:

        String SOQL = 'SELECT Id, Name, ( SELECT Id, Name FROM Contacts ), CountryLookup__r.Name FROM Account WHERE Name LIKE \'%' + String.escapeSingleQuotes(ld.Company) + '%\' LIMIT 100';
        List < Account > = listAccount = Database.query(SOQL);


No comments:

Post a Comment

Sharing is Caring!!! Share this with your friends!!!

submit to reddit