SqlStatement Class

Encapsulates the inputs required to execute a Data 360 SQL query against a data space. Build a statement from a raw SQL string or a pre-built ConnectApi.QuerySqlInput object, and then execute synchronously with SqlRowIterator or pass it to a SqlQueueable subclass for asynchronous processing.

Namespace

sfsqlquery

Usage

Use the static create() factories to build a statement, optionally configure the workload name with withWorkloadName(), and then either call execute() to get a synchronous SqlRowIterator or pass the statement to a SqlQueueable subclass for asynchronous execution.

Example

Build and execute a statement synchronously.

SqlStatement Methods

The following are methods for SqlStatement.

create(query, dataspace)

Creates a SqlStatement from a pre-built ConnectApi.QuerySqlInput object. Use this method when you need to configure query properties beyond a SQL string, such as parameterized queries, a server-side row limit, or custom query settings.

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

Note

Signature

public static sfsqlquery.SqlStatement create(ConnectApi.QuerySqlInput query, String dataspace)

Parameters

query
Type: ConnectApi.QuerySqlInput
Pre-built query input object that can include parameterized queries, a server-side row limit, or custom query settings.
dataspace
Type: String
Name of the Data 360 data space to query against.

Return Value

Type: sfsqlquery.SqlStatement

A new SqlStatement instance configured with the provided query input and data space.

create(sql, dataspace)

Creates a SqlStatement from a raw SQL string and a data space name.

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

Note

Signature

public static sfsqlquery.SqlStatement create(String sql, String dataspace)

Parameters

sql
Type: String
SQL query string to execute.
dataspace
Type: String
Name of the Data 360 data space to query against.

Return Value

Type: sfsqlquery.SqlStatement

A new SqlStatement instance configured with the provided SQL and data space.

execute()

Returns a synchronous SqlRowIterator built from this statement. Equivalent to new sfsqlquery.SqlRowIterator(statement). The query isn't submitted until iteration begins.

Signature

public sfsqlquery.SqlRowIterator execute()

Return Value

Type: sfsqlquery.SqlRowIterator

A new SqlRowIterator configured from this statement.

toString()

Returns a string representation of this SqlStatement.

Signature

public String toString()

Return Value

Type: String

A string representation of this SqlStatement.

withWorkloadName(name)

Sets the workload name to send with the query and returns the same SqlStatement instance for method chaining. If not set, the framework uses dcsql_row_iterator_workload for iterators or dcsql_queueable_workload for queueables.

Signature

public sfsqlquery.SqlStatement withWorkloadName(String name)

Parameters

name
Type: String
Custom workload name to associate with the query. Set this value to help Salesforce Customer Support assist you with debugging issues

Return Value

Type: sfsqlquery.SqlStatement

This SqlStatement instance.

Example

Use custom workload names to monitor and throttle different query types: