The INVALID_QUERY_LOCATOR error and related extended error codes indicate the query locator included in a call for additional query results is invalid or doesn’t exist.
When results for a large or complex query cannot be returned in a single response, Salesforce creates one or more server-side cursors. Cursors point to the location of additional query results in the database. These additional results are retrieved using a query locator within another call — such as the queryMore() call in the SOAP API or the nextRecordsUrl field in the REST API.
For example, consider a query where the batch size is set to 2,000 and the organization has more than 2,000 accounts. In this scenario, SELECT id FROM account returns 2,000 records and a query locator, indicating where the additional call can find and retrieve the remaining records.
A query locator is 18 characters long and begins with the prefix 0r8. Each locator and its associated results are available for two days after the initial query executes. Using an invalid or expired query locator in a call throws an INVALID_QUERY_LOCATOR error.
When you receive the INVALID_QUERY_LOCATOR error, review the extended error code in the response to identify the root cause and apply the appropriate resolution:
For full details on extended error codes, see the ExtendedErrorCode section of the SOAP API Developer Guide.
Salesforce SOAP API Developer Guide: query()
Salesforce REST API Developer Guide: Query
SOQL and SOSL Limits for Search Queries
Core Data Types Used in API Calls
Apex Developer Guide: Using Apex Variables in SOQL and SOSL Queries
000384958

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.