Pages

Monday, January 31, 2011

How to embed a string inside a SOQL query string?

Below is the syntax to do this.. Note that you have a string inside a string and the syntax to do so, the backslash followed by the single quote is the syntax.
public with sharing class forcetree 
{
 String squery = 'Select Id from User where Name=\'forcetree\'';
 Database.query(squery);
}

No comments:

Post a Comment