You need to sign in to do that
Don't have an account?

dynamic SOQL query????
Hi,
string namevf=name;
For(Contact objContact:[SELECT :namevf,id,MailingStreet,MailingCity,MailingCountry,MailingState FROM Contact])
{
//some code
}
in the above code , I want to replace ":namevf" with "name"(or any other API name) if I store the API name in another string variable ...
can any one help me on this......
string namevf=name;
For(Contact objContact:[SELECT :namevf,id,MailingStreet,MailingCity,MailingCountry,MailingState FROM Contact])
{
//some code
}
in the above code , I want to replace ":namevf" with "name"(or any other API name) if I store the API name in another string variable ...
can any one help me on this......
1. If you need to dynamically pick fields from a SOQL query you have to options:Add all the potential fields you'll be selecting to your SOQL query
2. Use Dynamic SOQL (http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dynamic_soql.htm)For the latter you would construct your SOQL in a string like so: