# mysql\_stmt\_attr\_get

## Syntax

```c
my_bool mysql_stmt_attr_get(MYSQL_STMT * stmt,
                            enum enum_stmt_attr_type,
                            void * attr);
```

* `stmt` - a statement handle, which was previously allocated by [mysql\_stmt\_init()](/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_init.md).
* `enum_stmt_attr_type` - attribute. See below.
* `attr` - pointer to a variable, which will contain the attribute value.

## Description

Gets the current value of a statement attribute. Returns zero on success, non zero on failure.

### Attribute types

The `enum_stmt_attr_type` parameter has the following possible values:

* `STMT_ATTR_UPDATE_MAX_LENGTH`: Indicates if [mysql\_stmt\_store\_result()](/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_store_result.md) will update the max\_length value of MYSQL\_FIELD structures.

  ```c
  my_bool is_update;
  rc= mysql_stmt_attr_get(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &is_update);
  ```
* `STMT_ATTR_CURSOR_TYPE`: Cursor type. Possible values are `CURSOR_TYPE_READ_ONLY` or default value `CURSOR_TYPE_NO_CURSOR`.

  ```c
  unsigned long cursor_type;
  rc= mysql_stmt_attr_get(stmt, STMT_ATTR_CURSOR_TYPE, &cursor_type);
  ```
* `STMT_ATTR_PREFETCH_ROWS`: Number of rows which will be prefetched. The default value is 1.

  ```c
  unsigned long prefetch_rows;
  rc= mysql_stmt_attr_get(stmt, STMT_ATTR_PREFETCH_ROWS, &prefetch_rows);
  ```
* `STMT_ATTR_PREBIND_PARAMS`: Number of parameters used for [mariadb\_stmt\_execute\_direct()](/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mariadb_stmt_execute_direct.md)

  ```c
  unsigned int param_count;
  rc= mysql_stmt_attr_get(stmt, STMT_ATTR_PREBIND_PARAMS, ¶m_count);
  ```

{% hint style="info" %}
Setting the number of prefetched rows will work only for read only cursors.
{% endhint %}

## See Also

* [mysql\_stmt\_attr\_set()](/docs/connectors/mariadb-connector-c/api-prepared-statement-functions/mysql_stmt_attr_set.md)

{% @marketo/form formId="4316" %}


---

# 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/mysql_stmt_attr_get.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.
