Newer Version Available

This content describes an older version of this product. View Latest

QueryLocatorIterator Class

Represents an iterator over a query locator record set.

Namespace

Database

Example

This sample shows how to obtain an iterator for a query locator, which contains five accounts. This sample calls hasNext and next to get each record in the collection.

QueryLocatorIterator Methods

The following are methods for QueryLocatorIterator. All are instance methods.

hasNext()

Returns true if there are one or more records remaining in the collection; otherwise, returns false.

Signature

public Boolean hasNext()

Return Value

Type: Boolean

next()

Advances the iterator to the next sObject record and returns the sObject.

Signature

public sObject next()

Return Value

Type: sObject

Usage

Because the return value is the generic sObject type, you must cast it if using a more specific type. For example:

Example