• Nagababu B
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
i write a program in this way but it gives an error

program:
list<student__c>stlist=new list<student__c>();
list<sports__c>splist=new list<sports__c>();
list<library__c>liblist=new list<library__c>();
list<student__c>stlist=[select id, Name, email__c, fee__c, sports__r.sports_name__c, sports__r.sports_cost__c, sports__r.sports_type__c, sports__r.libraries__r.Name, sports__r.libraries__r.book_type__c, sports__r.library__r.book_amount__c from student__c where country__c='INDIA'];
for(student__c st:stlist)
{
    system.debug('student record is' +st);
    system.debug('sports record is' +st.sports__r);
     system.debug('library record is' +st.sports__r.library__r);
    st.state__c='AP';
    st.city__c='hyd';
    st.email__c='ABC@cap.com';
    stlist.add(st);
    st.sports__r.sports_cost__c=1000;
    st.sports__r.sports_type__c='cricket';
    splist.add(st.sports__r);
    st.sports__r.library__r.book_type__c='technical';
    st.sports__r.library__r.book_amount__c=999;
    liblist.add(st.sports__r.library__r);
}
if(stlist.size()>0 && stlist!=null)
    update stlist;
if(splist.size()>0 && splist!=null)
    update splist;
if(liblist.size()>0 && liblist!=null)
    update liblist;

error:
Didn't understand relationship 'sports__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.
please give me a solution