Activity Forums Salesforce® Discussions What are Cursors in Salesforce?

  • Manpreet

    Member
    April 25, 2017 at 1:38 pm

    What exactly do we mean if we say "A user can have up to 50 query cursors open at a time".

  • Saurabh

    Member
    April 25, 2017 at 2:41 pm

    Hi Manpreet

    a cursor is a reference to the the result set for a soql query.

    Select Id, name, (select Id, name from contacts) from account

    Will account for 2 open cursors.

    The way out was to simplify the soql queries and break what we were trying to achieve in one batch apex class over 2 classes.

    Hope it may help

  • Avnish Yadav

    Member
    September 29, 2018 at 8:30 pm

    Cursors, as I understand, are the equivalent of query result sets. A similar concept exists in SQL if you're familiar with it.

    So I'd say a cursor is a reference to the result set for a soql query.

    I had a support case with Salesforce a while ago about cursors exceeded in a batch apex query. Apparently even inner queries will account for their own cursor set

    So
    Select Id, name, (select Id, name from contacts) from account

    Will account for 2 open cursors.

    The way out was to simplify the SOQL queries and break what we were trying to achieve in one batch apex class over 2 classes.

  • Shweta

    Member
    January 23, 2020 at 2:16 pm

    Cursors : It is equivalent to the Soql query result set. In cursor a user can have up to 10 query cursors open at a time. If 10 QueryLocator cursors are open in the application and  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.

Viewing 1 - 4 of 4 posts

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos