function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ad_InfosysAd_Infosys 

Error in the result set when using list.

I have a query in for loop the brings records in a list.
 
for(task ta_id:[select whatid from task where owneradentid__c='0' ])
listtest.add(ta_id.whatid);
 
now this list contains 54 records. (2 unique records that are repeated)
 
opportunitycontactrole[] opconr=[select opportunitycontactrole.opportunity.of_pending_stips__c from opportunitycontactrole where opportunityid in : listtest];
 
NOw I want a result set of 54 records but opconr has only 2 records comparing to the 2 unique records in the list
 
How do I do this.
Thanks in advance
werewolfwerewolf
So wait, you're saying that your list of opp IDs actually contains the same 2 ids repeated over and over?
Ad_InfosysAd_Infosys

Yes. The result is basically 2 unique results repeated again and again to make 54 results.

Now I want other SOQL to give result for 54 results but it gives me only for 2 unique.

 

I cannot use for loop as this will bring my code close to governor limit of 100 SOQL