Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can any one please help me out with below query..

String query = 'SELECT ID FROM Account WHERE Name = '\+Test+\'';

database.query(query);

getting error:-

line breaks not allowed in string literals

tried this as well

String query = 'SELECT ID FROM Account WHERE Name = '\+Test+\'';
share|improve this question
up vote 6 down vote accepted

Try a query like this:

String query = 'SELECT ID FROM Account WHERE Name = \'Test\'';
database.query(query);

If you find this string modification difficult, then use an online tool.

Select javascript and enter your query like SELECT ID FROM Account WHERE Name = 'Test' and click submit. The output will be:

var myvar = 'SELECT ID FROM Account WHERE Name = \'Test\'';

Just change var to String and use in your query.

share|improve this answer
    
thank you.... :-) – user28158 Jan 30 at 8:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.