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 8 years, 6 months ago by  Piyush.
    • This discussion was modified 8 years, 4 months ago by  Forcetalks.
    • This discussion was modified 8 years, 4 months ago by  Forcetalks.
    Ajit replied 8 years, 6 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