QueryHandle Class

Tracks the runtime execution state of a Data 360 SQL query as it progresses through submission, execution, and result retrieval. Use QueryHandle to resume a previously submitted query from a saved query ID in a new SqlRowIterator or a new SqlQueueable job.

sfsqlquery

QueryHandle doesn’t expose getters to subscribers. All internal state—query ID, data space, workload name, offset, and lifecycle flags—is managed by SqlRowIterator and SqlQueueable. Use SqlRowIterator.getQueryId() or SqlQueueable.getQueryId() to retrieve the query ID. When you resume from a saved query ID, call withOffset() to tell the framework how many rows were already processed so it resumes from the correct position.

Resume a previously submitted query:

The following are methods for QueryHandle.

Creates a QueryHandle from a previously submitted query ID and data space name. Use this method to resume fetching results for a query that was submitted in an earlier transaction.

Keep the class name and .create() on the same line when chaining methods.

public static sfsqlquery.QueryHandle create(String queryId, String dataspace)

  • queryId:

    Type: String

    ID of a previously submitted query, obtained from getQueryId() on a SqlRowIterator or SqlQueueable.

  • dataspace:

    Type: String

    Name of the Data 360 data space the original query was submitted against.

Type: sfsqlquery.QueryHandle

A new QueryHandle instance for the specified query.

Returns a string representation of this QueryHandle.

public String toString()

Type: String

A string representation of this QueryHandle.

Sets the row offset at which to begin fetching results and returns the same QueryHandle instance for method chaining. Use this when resuming a query to skip rows that were already processed.

public sfsqlquery.QueryHandle withOffset(Long offset)

  • offset:

    Type: Long 0-based row offset at which to begin fetching results.

Type: sfsqlquery.QueryHandle

This QueryHandle instance.

Resume processing after 500 rows were already processed:

Sets the workload name to use when fetching results and returns the same QueryHandle instance for method chaining.

public sfsqlquery.QueryHandle withWorkloadName(String name)

  • name:

    Type: String

    Custom workload name to associate with result fetch requests. Set this value to help Salesforce Customer Support assist you with debugging issues

Type: sfsqlquery.QueryHandle

This QueryHandle instance.