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

Question on SOQL Apex
i have an object called ScoringRule. ScoringRule has these fields - FldName, Operator1, Val1, Operator2, Val2, Score. This would return me more than 1 record.
How can i loop through the records? I dont want to display it on a page but i want to compare the fieldName__c with the lead object's field and apply some logic to it.
So i will have 2 queries:
// Get me the result from the query
ScoringRule__c score = [Select n.fieldName__c,
n.Val2__c, n.ScoringRule_Rule1__c, ScoringRule_Val1__c,
n.Score__c, n.Rule2__c
FromScoringRule__c n
where n.Val2__c != ''
and n.fieldName__c!=''];
Lead lead = [select FirstName, LastName, NumberOfEmployees, AnnualRevenue from lead]
I want to compare the fieldName__c with the the fields returned by the lead query.
Any help would be appreciated.
Regards
I think you should use lists of ScoringRule and Lead objects instead of single objects. Looping only makes sense when you have more than one record. So what you can do is:
List <ScoringRule__c> scores = [Select n.fieldName__c,
n.Val2__c, n.ScoringRule_Rule1__c, ScoringRule_Val1__c,
n.Score__c, n.Rule2__c
FromScoringRule__c n
where n.Val2__c != ''
and n.fieldName__c!=''];
List <Lead> leads = [select FirstName, LastName, NumberOfEmployees, AnnualRevenue from lead];
for(ScoringRule__c score : scores) {
for(Lead lead : leads) {
//do your comparisons here
}
}
cheers.
Mak