MySQL error 1305: Function or procedure does not exist
The stored function or procedure you called isn't defined in that database, or a built-in function name was misspelled or followed by a space.
- Error number
1305- Name
ER_SP_DOES_NOT_EXIST- SQLSTATE
42000- Category
- Databases, tables and columns
What it means
MySQL looked for a stored routine with that name in the current (or named) database and didn't find one. The message names the kind (FUNCTION or PROCEDURE) and the qualified name.
Common causes
- Calling a routine that lives in another database without qualifying it.
- A typo, or a built-in function that doesn't exist in this MySQL version.
- A space between a built-in function name and its parenthesis, which makes MySQL treat it as a user function (unless
IGNORE_SPACEis set). - Restoring a dump without its routines (
mysqldumpneeds--routines).
How to fix it
-
List the routines in the database.
SHOW PROCEDURE STATUS WHERE Db = DATABASE(); SHOW FUNCTION STATUS WHERE Db = DATABASE();
-
Qualify the routine with its database.
CALL reporting.refresh_totals();
-
When dumping, include routines:
mysqldump --routines --triggers shop > shop.sql.
Related errors
1318Incorrect number of arguments2812SQL Server: Could not find stored procedureORA-06508Oracle: PL/SQL: could not find program unit being called
More databases, tables and columns errors
1049Unknown database1046No database selected1054Unknown column in field list1146Table doesn't exist1050Table already exists1051Unknown table1060Duplicate column name1091Can't DROP; check that column/key exists
The code and message text are from the MySQL 8.4 Error Message Reference. Browse the full MySQL error list or search every database error.
Work on MySQL in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for MySQL and the other databases you use.