0

Error: Compile Error: Invalid bind expression type of String for column of type Decimal at line 395 column 176

How do I understand which field exactly to check? Here Baseline_Volume__c field is defined as Number in object.

public static Map<string, decimal> getRecruitmentDriverTaleoBaseline(string month,string year,string ref){


    decimal recruitmentVolume = 0.0;              
    Set<String> countryList = DriverCountry__c.getAll().keySet();    
    Map<string,decimal> driverVolumeMap = new Map<string, decimal>();       

    Map<string,string> countryNameMap = returncountryNameMap();
line 395 ---> for(AdjustmentObj__c adj : [Select Id, Reference_Number__c, Country__c, Baseline_Volume__c, Month__c, Year__c from AdjustmentObj__c where Month__c =: month and Year__c =: year and Reference_Number__c =: ref]){
    driverVolumeMap.put(adj.Month__c+SINGLE_DASH+adj.Country__c,adj.Baseline_Volume__c);
    }
    // LOOPING THROUGH THE LIST OF COUNTRIES TO INSERT THE WHOLE LIST IF ANY OF THOSE MISSED OUT IN THE DATA 
    for(String country : countryList){        
        if(!driverVolumeMap.containsKey(month+SINGLE_DASH+country) && ref != NUMBER_THIRTEEN && country != null){
            driverVolumeMap.put(month+SINGLE_DASH+country,0.0);
        }
    }
    return driverVolumeMap; 
}

The bold line is line 395.

5
  • It seems like Ref__c is number field but you are comparing it with String ref. Please check Year__c =: year as well.
    – Himanshu
    Commented Oct 6, 2015 at 8:18
  • Highlighted Line 395. Commented Oct 6, 2015 at 9:33
  • 2
    What are the types of your Month__c,Year__c and Ref__c fields?
    – highfive
    Commented Oct 6, 2015 at 9:38
  • Ref__c was typo . It's Reference_Number__c (Text), Month __c (Picklist) Year__c(Text) Commented Oct 6, 2015 at 9:50
  • It seems nearly certain you have mistaken one of your field types and that it is actually Number.
    – Adrian Larson
    Commented Sep 7, 2016 at 2:41

2 Answers 2

1

The clause in your SOQL

where Month__c =: month and Year__c =: year and Reference_Number__c =: ref

and the error message

Invalid bind expression type of String for column of type Decimal at line 395 column 176

is most likely, as @Himanshu said that Reference_Number__c is a field of type Number but local variable ref is of type String. Change to:

where Month__c =: month and Year__c =: year and Reference_Number__c =: Decimal.valueOf(ref)
0

Can we check/assign directly MyPicklist__C=: String value ?? I doubt that.

Will your try doing this -

.....  where Month __c IN (month) and Year__c =: year and  .....

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .