function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mamatha MasterMamatha Master 

single quote problem in query

Hi
 
While using API QueryResult  and query function i got an exception
 
+ System.SystemException {"MALFORMED_QUERY: \nId from Account where Name='cv's interest'\n                               ^\nERROR at Row:1:Column:44\nunexpected token: s interest"} System.SystemException
It's because of single quote(') in the query.
 
Here is my code:

sforce.QueryResult acc=sfc.query ("select Id,Name from Account where Name='cv's interest'");

Here account name=cv's interest having single quote in it.

It is causing that error.

 

Can anyone help me to over come this problem (single quote) while using query function of API

 

Thanks for your help

------MM

SuperfellSuperfell
You have to escape the single quote, e.g. where name='foo\'s shop'
xiaoluluxiaolulu
do you know how can I using replace replace single quote(') to \'
 
str.replace("'","\'") does not work.
 
thanks