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

Access Child Records in Parent-Child Relationship in apex
Hi folks,
Can anyone tell me how to access the child records in parent child relationship?
My code snippet as follows
Can anyone tell me how to access the child records in parent child relationship?
My code snippet as follows
List<Account> acc = [SELECT Id,Name,(SELECT Id,LastName FROM Contacts) FROM Account]; for(Account a: acc){ System.debug('CAaount name:'+ a.Name); //I dono how to acces contact s here for(Contact c:a.Contacts) { System.debug('Conatct Last:' +c.LastName); } Thanks in advance, Karthick
--
Abhi
If my answer helps to solve the issue/problem/doubt, please mark it as Best Answer; so that people who are stuck in the similar issue get benefitted.
am getting system.queryException: Invalid query locator.
To understand why this occurs, please go through - https://help.salesforce.com/apex/HTViewSolution?id=000004410&language=en_US (https://help.salesforce.com/apex/HTViewSolution?id=000004410&language=en_US)
--
Abhi
My usecase is to fetch all the accounts and its assocaited contacts
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm
http://www.salesforce.com/us/developer/docs/apex_workbook/Content/apex_batch_intro.htm
--
Abhi