# Stored Function Limitations

The following restrictions apply to [stored functions](https://mariadb.com/docs/server/server-usage/stored-routines/stored-functions).

* All of the restrictions listed in [Stored Routine Limitations](https://mariadb.com/docs/server/server-usage/stored-routines/stored-routine-limitations).
* Any statements that return a result set are not permitted. For example, a regular [SELECTs](https://mariadb.com/docs/server/reference/sql-statements/data-manipulation/selecting-data/select) is not permitted, but a [SELECT INTO](https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/selectinto) is. A cursor and [FETCH](https://mariadb.com/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-cursors/fetch) statement is permitted.
* [FLUSH](https://mariadb.com/docs/server/reference/sql-statements/administrative-sql-statements/flush-commands/flush) statements are not permitted.
* Statements that perform explicit or implicit commits or rollbacks are not permitted.
* Cannot be used recursively.
* Cannot make changes to a table that is already in use (reading or writing) by the statement invoking the stored function.
* Cannot refer to a temporary table multiple times under different aliases, even in different statements.
* ROLLBACK TO SAVEPOINT and RELEASE SAVEPOINT statement which are in a stored function cannot refer to a savepoint which has been defined out of the current function.
* Prepared statements ([PREPARE](https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/prepare-statement), [EXECUTE](https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/execute-statement), [DEALLOCATE PREPARE](https://mariadb.com/docs/server/reference/sql-statements/prepared-statements/deallocate-drop-prepare)) cannot be used, and therefore nor can statements be constructed as strings and then executed.

<sub>*This page is licensed: CC BY-SA / Gnu FDL*</sub>

{% @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/server/server-usage/stored-routines/stored-functions/stored-function-limitations.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.
