# MariaDB Connector/C API Prepared Statement Functions

- [mariadb\_stmt\_execute\_direct](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mariadb_stmt_execute_direct.md): mariadb\_stmt\_execute\_direct prepares and executes a statement in a single call using a pre-allocated MYSQL\_STMT handle, available in Connector/C 3.0 with MariaDB 10.2 or later.
- [mariadb\_stmt\_fetch\_fields](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mariadb_stmt_fetch_fields.md): mariadb\_stmt\_fetch\_fields returns an array of MYSQL\_FIELD descriptors for each result set column of a prepared statement, added in MariaDB Connector/C 3.1.0.
- [mysql\_stmt\_affected\_rows](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_affected_rows.md): mysql\_stmt\_affected\_rows returns the number of rows affected by the last INSERT, UPDATE, DELETE, or REPLACE prepared statement, or -1 if the statement failed.
- [mysql\_stmt\_attr\_get](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_attr_get.md): mysql\_stmt\_attr\_get retrieves the current value of a prepared statement attribute, such as cursor type, prefetch row count, or max-length update behavior.
- [mysql\_stmt\_attr\_set](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_attr_set.md): mysql\_stmt\_attr\_set configures a prepared statement attribute on a Connector/C statement handle; supported attributes include cursor type, prefetch rows, and bulk-insert array size.
- [mysql\_stmt\_bind\_param](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_bind_param.md): mysql\_stmt\_bind\_param binds an array of MYSQL\_BIND variables to the parameter markers in a prepared statement before it is executed via mysql\_stmt\_execute.
- [mysql\_stmt\_bind\_result](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_bind_result.md): mysql\_stmt\_bind\_result maps result-set columns to application variables via an array of MYSQL\_BIND structures, enabling mysql\_stmt\_fetch to populate those variables.
- [mysql\_stmt\_close](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_close.md): mysql\_stmt\_close deallocates a prepared statement handle and cancels any pending results, freeing server and client resources associated with the statement.
- [mysql\_stmt\_data\_seek](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_data_seek.md): mysql\_stmt\_data\_seek positions the row cursor to an arbitrary offset in a buffered prepared statement result set previously stored with mysql\_stmt\_store\_result.
- [mysql\_stmt\_errno](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_errno.md): mysql\_stmt\_errno returns the numeric error code for the most recently invoked Connector/C prepared statement function, or zero if no error occurred.
- [mysql\_stmt\_error](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_error.md): mysql\_stmt\_error retrieves the human-readable error message from the last Connector/C prepared statement call, complementing the numeric code from mysql\_stmt\_errno.
- [mysql\_stmt\_execute](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_execute.md): mysql\_stmt\_execute runs a prepared statement previously set up with mysql\_stmt\_prepare, substituting bound parameter values and returning zero on success.
- [mysql\_stmt\_fetch](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_fetch.md): mysql\_stmt\_fetch retrieves the next row from a prepared statement result set into the buffers bound by mysql\_stmt\_bind\_result, returning MYSQL\_NO\_DATA at end of set.
- [mysql\_stmt\_fetch\_column](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_fetch_column.md): mysql\_stmt\_fetch\_column fetches part of a single column value from the current prepared statement row, allowing large data to be read incrementally via an offset.
- [mysql\_stmt\_field\_count](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_field_count.md): mysql\_stmt\_field\_count reports how many fields a prepared statement result set contains; it returns zero for INSERT, UPDATE, DELETE, and REPLACE statements.
- [mysql\_stmt\_free\_result](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_free_result.md): mysql\_stmt\_free\_result frees client-side result memory for a Connector/C prepared statement, complementing mysql\_stmt\_store\_result to manage buffer lifecycle.
- [mysql\_stmt\_init](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_init.md): mysql\_stmt\_init allocates and initializes a MYSQL\_STMT prepared statement handle for a Connector/C connection, returning NULL if memory allocation fails.
- [mysql\_stmt\_insert\_id](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_insert_id.md): mysql\_stmt\_insert\_id returns the AUTO\_INCREMENT value generated by the most recent prepared INSERT or UPDATE statement, or zero if no auto-increment column was affected.
- [mysql\_stmt\_next\_result](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_next_result.md): mysql\_stmt\_next\_result advances to the next result set when a prepared statement returns multiple results, enabling traversal of multi-statement query output.
- [mysql\_stmt\_num\_rows](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_num_rows.md): mysql\_stmt\_num\_rows returns the total row count of a buffered prepared statement result set; it requires mysql\_stmt\_store\_result to have been called first.
- [mysql\_stmt\_param\_count](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_param_count.md): mysql\_stmt\_param\_count reports how many placeholder parameters a prepared statement contains, indicating the size of the MYSQL\_BIND array required for binding.
- [mysql\_stmt\_param\_metadata](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_param_metadata.md): mysql\_stmt\_param\_metadata retrieves parameter metadata for a prepared statement handle, returning a MYSQL\_RES pointer that describes the bound parameters.
- [mysql\_stmt\_prepare](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_prepare.md): mysql\_stmt\_prepare parses and prepares a SQL statement on a Connector/C MYSQL\_STMT handle; parameter markers must be bound with mysql\_stmt\_bind\_param before execution.
- [mysql\_stmt\_reset](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_reset.md): mysql\_stmt\_reset resets a prepared statement on both client and server to its post-prepare state, clearing unbuffered results and errors while preserving bindings.
- [mysql\_stmt\_result\_metadata](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_result_metadata.md): mysql\_stmt\_result\_metadata retrieves result-set metadata from a Connector/C prepared statement; the returned MYSQL\_RES contains field information but no row data.
- [mysql\_stmt\_row\_seek](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_row_seek.md): mysql\_stmt\_row\_seek positions the row cursor to an arbitrary row in a buffered prepared statement result set, returning the previous cursor offset for later restoration.
- [mysql\_stmt\_row\_tell](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_row_tell.md): mysql\_stmt\_row\_tell returns the current row cursor offset of a buffered prepared statement result set, which can be passed to mysql\_stmt\_row\_seek to restore the position.
- [mysql\_stmt\_send\_long\_data](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_send_long_data.md): mysql\_stmt\_send\_long\_data sends a parameter value in chunks to the server, enabling large TEXT or BLOB data that exceeds max\_allowed\_packet to be streamed in multiple calls.
- [mysql\_stmt\_sqlstate](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_sqlstate.md): mysql\_stmt\_sqlstate returns the five-character SQLSTATE error code for the most recently invoked prepared statement function, with '00000' indicating no error occurred.
- [mysql\_stmt\_store\_result](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_store_result.md): mysql\_stmt\_store\_result buffers the complete result set of a prepared SELECT, SHOW, DESCRIBE, or EXPLAIN statement on the client, enabling random access and row count queries.
- [mysql\_stmt\_warning\_count](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_warning_count.md): mysql\_stmt\_warning\_count reports how many warnings the most recent Connector/C prepared statement raised; added in Connector/C 3.0. Use SHOW WARNINGS to retrieve messages.
- [Connector C Data Structures and Definitions](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/connector-c-data-structures-and-definitions.md): Explore practical examples of prepared statements. Learn how to use them to enhance application security against SQL injection and improve query performance by optimizing statement execution.
- [Connector/C Types and Definitions](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/connector-c-data-structures-and-definitions/connectorc-types-and-definitions.md): Connector/C field types and indicator variables used in the MYSQL\_BIND structure, including all MYSQL\_TYPE constants and STMT\_INDICATOR values defined in mariadb\_com.h.
- [MYSQL\_BIND](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/connector-c-data-structures-and-definitions/mysql_bind.md): MYSQL\_BIND is the MariaDB Connector/C structure used to bind input parameters and output result columns to a prepared statement, with support for array binding and indicator variables.
- [MYSQL\_STMT](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/connector-c-data-structures-and-definitions/mysql_stmt.md): MYSQL\_STMT is the MariaDB Connector/C handle for a prepared statement, allocated by mysql\_stmt\_init and released by mysql\_stmt\_close; all its members are private.
- [Prepared Statement Examples](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/prepared-statement-examples.md): Prepared statement examples
- [Bulk Insert (Column-wise Binding)](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/prepared-statement-examples/bulk-insert-column-wise-binding.md): Insert multiple rows in a single prepared statement call using column-wise binding. This example demonstrates indicator variables and STMT\_ATTR\_ARRAY\_SIZE with MariaDB Connector/C.
- [Bulk Insert (Row-wise Binding)](https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/prepared-statement-examples/bulk-insert-row-wise-binding.md): Insert multiple rows in a single prepared statement call using row-wise binding. This example packs parameters into a C struct and sets STMT\_ATTR\_ROW\_SIZE for MariaDB Connector/C.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/connectors/mariadb-connector-c/api-prepared-statement-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
