invalid query locator error occurs when iterating child objects in parent-child relationship query result

Apex

Last updated 4 days ago ·Reference W-2503825 ·Reported By 152 users

In Review

Summary
Invalid query locator error occurs when iterating child objects in parent-child relationship query result if CLOB fileds are included in the query and there are 200 child records.

Repro
1. create custom objects
a. Master
Name : Master
b. Child
Name : Child
2. add fields to the above custom objects
a. to Master
a-1. LongTextA
Name : LongTextA
Type : Long Text Area
Length : 131072
a-2. LongTextB
Name : LongTextB
Type : Long Text Area
Length : 131072
b. to Child
a-1. Master
Name : Master
Type : Master-Detail
Relate To : Master
3. create records by the following Apex code
---
Master__c m = new Master__c(Name='TEST');
insert m;
List<Child__c> children = new List<Child__c>();
for(integer i=0; i<200; i++) {
child__c c = new Child__c(Name='TEST'+i, Master__c=m.Id);
children.add(c);
}
insert children;
---
* run from Developer Console
4. run the following Apex code from Developer Console
---
Master__c m = [SELECT Name, LongTextA__c, LongTextB__c, (SELECT Name FROM Child__r) FROM Master__c LIMIT 1];
Integer count = 0;
for(Child__c c : m.Child__r) {
count++;
}
System.debug(count);
---
You will see that "System.QueryException: invalid query locator" occurs.

Workaround
decrease the number of CLOB field(s) from query
split a query to parent object query and child object query

Reported By (152)

Evan Kerr Jagadeesh Kureti Jeet Patel David Polehonski Dan Goldberg Sharad Maheshwari Jimmy Pomella Luxent Support Kevin Antonioli Petr Jezek Vinicius Zanquini gaurav arora Luis Arismendy Lianne Trantz Sai Ayta Hung Nguyen Julia Allinder Kyle King Cameron Bartlett Adolfo Contreras Antonio Diaz Andrew Chico Jesus Martinez Fernandez Gwenael Lesaulnier Andrew Craddock Jon Wilson James Woodward José Antonio Campaña Jose Manuel Garrido Morgado Aníbal García García Jack Creighton David Frudd Alberto David Fernández Alejandro Molina Salazar Jahiel Ramirez Cristina Sanchez Javier Labrat Simon Ejsing Elisabeth Segura Angel Luis Pinar James Hadfield Daniel Butler-Taverner Javier Coca Avinash Nelluri Ryan Taylor Elaine Young Ben Heiss Steve Brock Dave Berry Robert Strunk Jennifer Pandiscio John Stevens Kevin Fleck Kari Fines Rani Zilbergeld Oleg Yurev Paras Dhingra Matthew Schetselaar Dino Kozić Petar Markovic Antun Bartonicek Igor Malički Alessandro Bello Igor Vrabec Dario Kos Danijel Scuric Nikol Badanjak Maja Pasaric Nina Katic Marijan Barisin Ranko Miklin Bojan Zunko Mario Lukica Saurabh Kumar Shermal Warnakula Terry Cole Ricardo Portela Vijay Prakash Vrajesh Sheth Vladimir Khryshchanovich Alexandr Luferov Dhruv Bhalodi Alexandru Radulescu Jhomann Carreon Chaithanya Godla Paul Dodds Grant Adamson Rachit Saxena Syvain Picory Stefanie Riechel M Kher Andrew Lokotosh Matt Vitale David Griffiths architha kunamalla Dileep Tandra Henry Wong Jair Zheng Albert HL Hu Tadeas B. Colin Kenworthy Daniel O'Brien Jake Hebert Varun N Rittu Roy Nathan Woolley Davie Ching Ricky Hewitt Rachael Moore Andy Watkins 麻希子 久住 Magnus Vogel Mark Malanowski Tony Ly Gorana Grubisic Matija Corluka Ivan Vrtarić Nikola Rendulic Marko Cekol Ranko Miklin Anton Banic Ivan Vragović Tomislav Blazek Ivan Tadic Danijel Turkovic Stjepan Martinic Ilija Pavlic Arun C 真沙代 小坂 Sensis Support Benedict Bartolome Erika Hidalgo Timothy James Bagain Jeric Punsalan Jade Serrano Maedelle Maghanoy Mariane Aquino EHSAN MAHMOUDI Gab Tan Kresimir Tonkovic Andy Watkins Josip Letica Pankaj Agrawal Stanley Dev4 Pei Huang Pujitha Madamanchi Michael Smith (DO NOT USE) Michael Richmond Mike Ewan Ernesto Valdes Christian Warden Akira Kuratani

Is it Fixed?

AP0 AP3 AP4 AP5 AP6 AP7 AP8 AP9 AP14 AP15 AP20 AP21 AP22 AP28 CS1 CS2 CS3 CS4 CS5 CS6 CS7 CS8 CS9 CS10 CS109 CS108 CS107 CS106 CS105 CS102 CS101 CS100 CS115 CS110 CS11 CS116 CS12 CS137 CS138 CS13 CS14 CS148 CS142 CS15 CS152 CS151 CS16 CS17 CS18 CS19 CS20 CS21 CS22 CS23 CS24 CS25 CS26 CS27 CS28 CS29 CS30 CS31 CS32 CS33 CS34 CS35 CS36 CS37 CS40 CS41 CS42 CS43 CS44 CS45 CS47 CS50 CS51 CS52 CS53 CS54 CS57 CS58 CS59 CS60 CS61 CS62 CS63 CS64 CS65 CS66 CS67 CS68 CS69 CS70 CS71 CS72 CS73 CS74 CS75 CS76 CS77 CS78 CS79 CS80 CS81 CS82 CS83 CS84 CS85 CS86 CS87 CS88 CS89 CS90 CS91 CS92 CS93 CS94 CS95 CS96 CS97 CS98 CS99 EU7 EU8 EU10 EU12 EU13 EU14 EU15 EU16 EU17 EU18 EU19 EU25 EU26 EU29 EU30 NA104 NA109 NA100 NA101 NA103 NA102 NA105 NA119 NA110 NA112 NA111 NA117 NA129 NA124 NA122 NA130 NA136 NA135 NA132 NA131 NA146 NA142 NA141 NA154 NA155 NA196 NA21 NA32 NA37 NA39 NA42 NA44 NA45 NA46 NA47 NA49 NA51 NA52 NA53 NA54 NA56 NA57 NA58 NA59 NA60 NA61 NA62 NA63 NA64 NA65 NA66 NA67 NA68 NA69 NA70 NA71 NA72 NA73 NA74 NA75 NA76 NA77 NA78 NA79 NA80 NA81 NA82 NA83 NA84 NA85 NA86 NA87 NA88 NA89 NA90 NA91 NA92 NA93 NA94 NA95 NA96 NA97 NA98 NA99 UM1 UM2 UM3 UM4 UM5

Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.