Activity Forums Salesforce® Discussions Getting error while running SOQL declared as String

  • Getting error while running SOQL declared as String

    Posted by Piyush on April 30, 2016 at 6:21 PM

    Declared a string and assigned SOQL value as shown below. While running I am getting an error.

    String country = 'United States';
    String accountQuery = 'SELECT Id,BillingPostalCode,County_Name__c '+
    'FROM Account WHERE zipCodeLen__c =9 AND AND BillingCountry = '+ Country;

    • This discussion was modified 10 years, 3 months ago by  Piyush.
    • This discussion was modified 10 years, 1 month ago by  Forcetalks.
    • This discussion was modified 10 years, 1 month ago by  Forcetalks.
    Ajit replied 10 years, 2 months ago 2 Members · 1 Reply
  • 1 Reply
  • Ajit

    Member
    May 24, 2016 at 9:46 AM

    Hey Piyush

    Try this query

    String accountQuery = 'SELECT Id,BillingPostalCode,County_Name__c '+
    'FROM Account WHERE zipCodeLen__c = 9 AND BillingCountry =: '+ Country;

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos

Pros & Cons of Lightning Component vs. 3rd party frameworks in Salesforce UI development

Video in

Nikita drops by to share his invaluable experience of using popular 3rd party frameworks in Salesforce. http://media.blubrry.com/salesforceway/audio.xmcdn.com/group42/M05/25/57/wKgJ81rXk6XjaZIAAU_I_KtprFM998.m4a  

Skip to toolbar