+ Start a Discussion

Need Help with "DML requires SObject or SObject list type: Decimal"

Here is the code I have written as of now and I'm trying to get my update working but it's telling me "DML requires SObject or SObject list type: Decimal". I'm not sure how I could resolve this error but any help would be greatly appreciated!

			//map<ID,FCC_Code_Entry__c[]> code =new map<string,Map<ID,FCC_Code_Entry__c[]>>();
			map<String,double> code =new map<String,double>();
			for(Price_Sheet_Code_Entry__c PSC:[select Charge_Amount__c,Code_Master__r.name from Price_Sheet_Code_Entry__c where Code_Price_Sheet__c=:tnew.SG_Charge_Price_Sheet__c]){
			for(FCC_Code_Entry__c codes:[select id,Reimbursement_Amount__c from FCC_Code_Entry__c  where Facility_Carrier_Contract__c =:tnew.Id]){
				double FCCCode=code.get(codes.Code_Master_Reference__r.name);
				double ReimAmt=(double.valueof(FCCCode)*double.valueof(tnew.Reimbursement_Rate__c));
				try {
				update codes.Reimbursement_Amount__c=ReimAmt; 
				} catch (DmlException e) {



Best Answer chosen by Admin (Salesforce Developers) 

try changing this:

update codes.Reimbursement_Amount__c=ReimAmt; 


to this:

update codes;


The reason is that the DML would run on the object (codes) and not the individual fields. 


However, this code is also bad because you are excuting DML in a loop and might run into salesforce limits.  The best way is to bulkify your code by doing the updates in memory on the object and then doing one massive DML statment after the loop.  The DML statement would then run an update on a list, collection, array, whatever instead of an individual record.