> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/server-usage/stored-routines/stored-functions/stored-function-limitations.md).

# Stored Function Limitations

This page details the restrictions on stored functions, such as the inability to return result sets or use transaction control statements.

The following restrictions apply to [stored functions](/docs/server/server-usage/stored-routines/stored-functions.md).

* All of the restrictions listed in [Stored Routine Limitations](/docs/server/server-usage/stored-routines/stored-routine-limitations.md).
* Any statements that return a result set are not permitted. For example, a regular [SELECTs](/docs/server/reference/sql-statements/data-manipulation/selecting-data/select.md) is not permitted, but a [SELECT INTO](/docs/server/reference/sql-statements/programmatic-compound-statements/selectinto.md) is. A cursor and [FETCH](/docs/server/reference/sql-statements/programmatic-compound-statements/programmatic-compound-statements-cursors/fetch.md) statement is permitted.
* [FLUSH](/docs/server/reference/sql-statements/administrative-sql-statements/flush-commands/flush.md) 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](/docs/server/reference/sql-statements/prepared-statements/prepare-statement.md), [EXECUTE](/docs/server/reference/sql-statements/prepared-statements/execute-statement.md), [DEALLOCATE PREPARE](/docs/server/reference/sql-statements/prepared-statements/deallocate-drop-prepare.md), [EXECUTE IMMEDIATE](/docs/server/reference/sql-statements/prepared-statements/execute-immediate.md)) cannot be used, and therefore nor can statements be constructed as strings and then executed. From MariaDB 13.2.1 they can be used, but only when the function is called on the right-hand side of an assignment to a stored routine variable. See [Dynamic SQL in Stored Functions](/docs/server/reference/sql-statements/prepared-statements/prepare-statement.md#dynamic-sql-in-stored-functions).

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

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