> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kinetica.com/llms.txt
> Use this file to discover all available pages before exploring further.

# execute_sql

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/execute_sql.rs#L49-L66)
pub async fn [execute\_sql](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/execute-sql.md#method.execute_sql)( \&self, statement: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), offset: [i64](https://doc.rust-lang.org/1.98.1/std/primitive.i64.html), limit: [i64](https://doc.rust-lang.org/1.98.1/std/primitive.i64.html), request\_schema\_str: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), data: [Vec](https://doc.rust-lang.org/1.98.1/alloc/vec/struct.Vec.html)\<[ByteBuf](https://docs.kinetica.com/content/api/rust/struct.ByteBuf.md)>, ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[ExecuteSqlResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.ExecuteSqlResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Execute a SQL statement (query, DML, or DDL)Execute a SQL statement (query, DML, or DDL).See SQL Support for the complete set of supported SQL commands.When a caller wants all the results from a large query (e.g., more than max\_get\_records\_size records), they can make multiple calls to this endpoint using the `offset` and `limit` parameters to page through the results. Normally, this will execute the `statement` query each time. To avoid re-executing the query each time and to keep the results in the same order, the caller should specify a paging\_table name to hold the results of the query between calls and specify the paging\_table on subsequent calls. When this is done, the caller should clear the paging table and any other tables in the result\_table\_list (both returned in the response) when they are done paging through the results. `paging_table` (and result\_table\_list) will be empty if no paging table was created (e.g., when all the query results were returned in the first call).

##### Arguments

<ul>
  <li>`statement` - SQL statement (query, DML, or DDL) to be executed.</li>
  <li>`offset` - A positive integer indicating the number of initial results to skip (this can be useful for paging through the results).</li>
  <li>`limit` - A positive integer indicating the maximum number of results to be returned, or END\_OF\_SET (-9999) to indicate that the maximum number of results allowed by the server should be returned. The number of records returned will never exceed the server’s own limit, defined by the max\_get\_records\_size parameter in the server configuration. Use `has_more_records` to see if more records exist in the result to be fetched, and `offset` and `limit` to request subsequent pages of results.</li>
  <li>`request_schema_str` - Avro schema of `data`.</li>
  <li>`data` - An array of binary-encoded data for the records to be binded to the SQL query. Or use query\_parameters to pass the data in JSON format.</li>
</ul>

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/execute_sql.rs#L107-L134)
pub async fn [execute\_sql\_with\_opts](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/execute-sql.md#method.execute_sql_with_opts)( \&self, statement: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), offset: [i64](https://doc.rust-lang.org/1.98.1/std/primitive.i64.html), limit: [i64](https://doc.rust-lang.org/1.98.1/std/primitive.i64.html), request\_schema\_str: [String](https://doc.rust-lang.org/1.98.1/alloc/string/struct.String.html), data: [Vec](https://doc.rust-lang.org/1.98.1/alloc/vec/struct.Vec.html)\<[ByteBuf](https://docs.kinetica.com/content/api/rust/struct.ByteBuf.md)>, options: [ExecuteSqlRequestOptions](https://docs.kinetica.com/content/api/rust/generated/api/struct.ExecuteSqlRequestOptions.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[ExecuteSqlResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.ExecuteSqlResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Execute a SQL statement (query, DML, or DDL)Execute a SQL statement (query, DML, or DDL).See SQL Support for the complete set of supported SQL commands.When a caller wants all the results from a large query (e.g., more than max\_get\_records\_size records), they can make multiple calls to this endpoint using the `offset` and `limit` parameters to page through the results. Normally, this will execute the `statement` query each time. To avoid re-executing the query each time and to keep the results in the same order, the caller should specify a paging\_table name to hold the results of the query between calls and specify the paging\_table on subsequent calls. When this is done, the caller should clear the paging table and any other tables in the result\_table\_list (both returned in the response) when they are done paging through the results. `paging_table` (and result\_table\_list) will be empty if no paging table was created (e.g., when all the query results were returned in the first call).

##### Arguments

<ul>
  <li>`statement` - SQL statement (query, DML, or DDL) to be executed.</li>
  <li>`offset` - A positive integer indicating the number of initial results to skip (this can be useful for paging through the results).</li>
  <li>`limit` - A positive integer indicating the maximum number of results to be returned, or END\_OF\_SET (-9999) to indicate that the maximum number of results allowed by the server should be returned. The number of records returned will never exceed the server’s own limit, defined by the max\_get\_records\_size parameter in the server configuration. Use `has_more_records` to see if more records exist in the result to be fetched, and `offset` and `limit` to request subsequent pages of results.</li>
  <li>`request_schema_str` - Avro schema of `data`.</li>
  <li>`data` - An array of binary-encoded data for the records to be binded to the SQL query. Or use query\_parameters to pass the data in JSON format.</li>
  <li>`options` - The optional parameters; any left unset take the server’s defaults.</li>
</ul>

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/execute_sql.rs#L138-L156)
pub async fn [execute\_sql\_request](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/execute-sql.md#method.execute_sql_request)( \&self, request: &[ExecuteSqlRequest](https://docs.kinetica.com/content/api/rust/generated/api/struct.ExecuteSqlRequest.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[ExecuteSqlResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.ExecuteSqlResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Sends a pre-built [`ExecuteSqlRequest`](https://docs.kinetica.com/content/api/rust/generated/api/struct.ExecuteSqlRequest) to the `/execute/sql` endpoint and decodes the records it returns. Only binary encoding is supported.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/execute_sql.rs#L160-L171)
pub async fn [execute\_sql\_raw](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/execute-sql.md#method.execute_sql_raw)( \&self, request: &[ExecuteSqlRequest](https://docs.kinetica.com/content/api/rust/generated/api/struct.ExecuteSqlRequest.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[RawExecuteSqlResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.RawExecuteSqlResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Sends a pre-built [`ExecuteSqlRequest`](https://docs.kinetica.com/content/api/rust/generated/api/struct.ExecuteSqlRequest) to the `/execute/sql` endpoint, returning the response as the server sends it.

[Source](https://github.com/kineticadb/kinetica-api-rust/blob/master/crates/gpudb-api/src/generated/execute_sql.rs#L175-L187)
pub async fn [execute\_sql\_from\_url](https://docs.kinetica.com/content/api/rust/gpudb/struct.Kinetica/execute-sql.md#method.execute_sql_from_url)( \&self, url: &[str](https://doc.rust-lang.org/1.98.1/std/primitive.str.html), request: &[ExecuteSqlRequest](https://docs.kinetica.com/content/api/rust/generated/api/struct.ExecuteSqlRequest.md), ) -> [Result](https://doc.rust-lang.org/1.98.1/core/result/enum.Result.html)\<[RawExecuteSqlResponse](https://docs.kinetica.com/content/api/rust/generated/api/struct.RawExecuteSqlResponse.md), [KineticaError](https://docs.kinetica.com/content/api/rust/errors/enum.KineticaError.md)>

Sends a pre-built [`ExecuteSqlRequest`](https://docs.kinetica.com/content/api/rust/generated/api/struct.ExecuteSqlRequest) to a specific worker URL, bypassing HA head-node selection. Used for multi-head access.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.