You need to sign in to do that
Don't have an account?
SunnyShiny
SOQL Apex code > string
Hello,
I dont know the right way to write down this
String val = 'Saler';
I tried >
String soqlQuery = 'Select id from Contact Where RecordType.Name = ' + 'Saler' + ' limit 1';
>
String soqlQuery = 'Select id from Contact Where RecordType.Name = ' + val + ' limit 1';
system.debug(soqlQuery);
But quotes disapears, how can I do ?
Thanks
http://boards.developerforce.com/t5/Apex-Code-Development/Variable-does-not-exist/td-p/595715
You can use:
This assumes that "val" will still be in scope when Database.query(soqlQuery) is called.
If this is not the case, use the following type of design:
This uses String.format and String.escapeSingleQuotes to properly create the dynamic SOQL string.