0

我有一个关于 sosl 的问题。

这工作正常:

List<List<SObject>> searchList = null;  
string startAddress = 'hello';  
searchList = Search.query('FIND \'' +startAddress + '\' IN ALL FIELDS RETURNING Account');

但是如果我写这样的东西,它会给我一个错误:

List<List<SObject>> searchList = null;  
string startAddress = 'Tom\'s Towing and Recovery';  

searchList = Search.query('FIND \'' +startAddress + '\' IN ALL FIELDS RETURNING Account');  

Error : System.QueryException: line 1:507 mismatched character '<EOF>' expecting '''

请为此问题提出解决方案。任何形式的帮助将不胜感激。

4

1 回答 1

1

请像这样转义输入:

string startAddress = string.escapeSingleQuotes( 'Tom\'s Towing and Recovery' );
于 2012-09-03T14:21:26.360 回答