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.
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.
Build and execute a statement synchronously.
The following are methods for SqlStatement.
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.
public static sfsqlquery.SqlStatement create(ConnectApi.QuerySqlInput query, String dataspace)
-
query:
Type: ConnectApi.QuerySqlInput
Pre-built query input object that c
an 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.
Type: sfsqlquery.SqlStatement
A new SqlStatement instance configured with the provided query input and data space.
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.
public static sfsqlquery.SqlStatement create(String sql, String dataspace)
-
sql:
Type: String
SQL query string to execute.
-
dataspace:
Type: String
Name of the Data 360 data space to query against.
Type: sfsqlquery.SqlStatement
A new SqlStatement instance configured with the provided SQL and data space.
Returns a synchronous SqlRowIterator built from this statement. Equivalent to new sfsqlquery.SqlRowIterator(statement). The query isn’t submitted until iteration begins.
public sfsqlquery.SqlRowIterator execute()
Type: sfsqlquery.SqlRowIterator
A new SqlRowIterator configured from this statement.
Returns a string representation of this SqlStatement.
public String toString()
Type: String
A string representation of this SqlStatement.
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.
public sfsqlquery.SqlStatement withWorkloadName(String name)
-
name:
Type: String
Custom workload name to associate with the query. Set this value to help Salesforce Customer Support assist you with debugging issues
Type: sfsqlquery.SqlStatement
This SqlStatement instance.
Use custom workload names to monitor and throttle different query types: