+ Start a Discussion
jontkjontk 

Batch select returns INVALID_QUERY_LOCATOR error

Has anyone experienced this INVALID_QUERY_LOCATOR error before?

I am running a simple select statement using the API query call and queryMore to retrieve records in batches and I am getting an INVALID_QUERY_LOCATOR error sporatically. The retrieval for the next set is well under 10 minutes and there are about 67,000 records that should be returned. I am using a batch size of 1000.

Thanks.
Jon
darozdaroz
More then likely you're running into a situation where it's too long beween query() and queryMore() or between subsequent queryMore() calls. What you need to do is interate through your query()/queryMore() calls and capture all the data locally before parsing through it. Memory hog... yes, but it works.
jontkjontk
I'll try that but the code that's running in between the query and queryMore is taking under a minute to execute so I'm a bit surprised if that's the case.
Thanks for advice, I'll give it a whirl and see what happens.
dhruvadhruva
Just for a sanity check, print your queryLocator value before and after each call. You've probably already done that....
SuperfellSuperfell
Is there other code running with the same user that's also creating cursors ? the 5 cursor limit is per userId.
jontkjontk
Thanks, I think that's what the issue was but I wnant to be clear on this.
The 5 cursor limit is per user id and NOT connection?

Thanks again!
Jon
SuperfellSuperfell
Yes, its per UserId, not per session.