function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

what is a querylocator and query cursor

Can anyone help me understand the terms queryLocator, queryMore() and query cursor. I found few docs but still not exactly clear on these topics.


QueryLocator is a method used to initialize the StandardSetController. When we want to give pagination control in the SEARCH visual force page. For ex:


Public ApexPages.standardSetController  setCon = new ApexPages.standardSetController(getQueryLocator(SOQL));


also refer:


Hi Shah,


Thanks for your reply.


Yes , it is one of the uses. Also do you have any idea about query cursors?

According to SFDC docs:

A user can have up to 10 query cursors open at a time. If 10QueryLocatorcursors are open when a client application, logged in as the same user, attempts to open a new one, then the oldest of the 10 cursors is released. If the client application attempts to open the released query cursor, an error results.


AQueryLocatorrepresents a server-side cursor.


So what do we mean exactly by query cursor. We are dong a POC where we are getting this.