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
vino2vijayvino2vijay 

What is the use Query()/QueryMore()/queryAll() ?

What is the use Query()/QueryMore()/queryAll() ?

Best Answer chosen by Admin (Salesforce Developers) 
gautam_singhgautam_singh

Use the query() call to retrieve data from an object. When a client application invokes the query() call, it passes in a query expression that specifies the object to query, the fields to retrieve, and any conditions that determine whether a given object qualifies.

QueryResult = connection.query(string queryString);



queryAll()

Retrieves data from specified objects, whether or not they have been deleted.Use queryAll to identify the records that have been deleted because of a merge or delete. queryAll has read-only access to the field isDeleted; otherwise it is the same as query().You can use queryAll() to query on all Task and Event records, archived or not. You can also filter on the isArchived field to find only the archived objects. You cannot use query() as it automatically filters out all records where isArchived is set to true. You can update or delete archived records, though you cannot update the isArchived field. If you use the API to insert activities that meet the criteria listed below, the activities will be archived during the next run of the archival background process.

QueryResult = connection.queryAll(string queryString);


queryMore()

QueryResult = connection.queryMore( QueryLocator QueryLocator);

Use this call to process query() calls that retrieve a large number of records (by default, more than 500) in the result set. The query() call retrieves the first 500 records and creates a server-side cursor that is represented in the queryLocator object. The queryMore() call processes subsequent records in up to 500-record chunks, resets the server-side cursor, and returns a newly generated QueryLocator. To iterate through records in the result set, you generally call queryMore() repeatedly until all records in the result set have been processed (the Done flag is true). You can change the maximum number of records returned to up to 2,000.

 A queryMore()call on a parent object invalidates all child cursors in the previous result set. If you need the results from the child, you must use queryMore() on those results before using queryMore() on the parent results.



Important :

Hit Kudo's and If you find this as answer to your question then mark it as an solution .