Error
Error Code:
1305
MySQL Error 1305: Stored Procedure Not Found
Description
MySQL Error 1305 indicates that the database management system cannot find a specific stored procedure, function, or event that your SQL statement is attempting to call or reference. This error typically occurs when the requested object either does not exist in the current database, is misspelled, or resides in a different database context.
Error Message
%s %s does not exist
Known Causes
3 known causesIncorrect Object Name
The name of the stored procedure, function, or event in your SQL statement does not exactly match its actual name in the database due to a typo or case sensitivity.
Wrong Database Context
Your SQL statement is being executed while connected to a database where the intended object does not exist, or the object belongs to a different schema.
Object Does Not Exist
The stored procedure, function, or event was never created in the database or has been previously dropped.
Solutions
4 solutions available1. Verify Stored Procedure Name and Schema easy
Double-check the spelling and schema of the stored procedure you are trying to call.
1
Carefully review the stored procedure name in your SQL query. Ensure there are no typos, extra spaces, or case sensitivity issues (depending on your OS and MySQL configuration).
SELECT * FROM mysql.proc WHERE name = 'your_stored_procedure_name';
2
If your stored procedure is not in the default `dbo` schema (or the schema you are currently connected to), you need to qualify its name with the correct schema. For example, `CALL my_schema.my_stored_procedure();`.
CALL schema_name.stored_procedure_name(argument1, argument2);
3
Connect to the specific database where the stored procedure is expected to exist and try calling it again. If you are connected to the wrong database, the procedure might not be found.
USE your_database_name;
CALL your_stored_procedure_name();
2. List Available Stored Procedures easy
Query the `mysql.proc` table to see all stored procedures in a specific database.
1
Execute a query against the `mysql.proc` table to list all stored procedures within your current database. This helps confirm if the procedure exists and its exact name.
SHOW PROCEDURE STATUS WHERE Db = 'your_database_name';
2
If the procedure is not found in the list, it means it hasn't been created or was dropped. You will need to create it.
CREATE PROCEDURE your_stored_procedure_name(...) BEGIN ... END;
3. Check for Stored Procedure Existence Before Calling medium
Use `IF EXISTS` to gracefully handle cases where a stored procedure might not be present.
1
When calling a stored procedure, especially in scripts or applications, it's good practice to check for its existence first. This prevents the error from occurring and allows for alternative actions.
DELIMITER //
CREATE PROCEDURE call_my_procedure_safely()
BEGIN
IF EXISTS (SELECT * FROM mysql.proc WHERE name = 'your_stored_procedure_name' AND db = DATABASE()) THEN
CALL your_stored_procedure_name();
ELSE
SELECT 'Stored procedure your_stored_procedure_name does not exist.' AS message;
END IF;
END //
DELIMITER ;
CALL call_my_procedure_safely();
4. Recreate the Stored Procedure medium
If the procedure is confirmed to exist but still causes the error, it might be corrupted or incompletely created.
1
First, verify that the stored procedure actually exists using `SHOW PROCEDURE STATUS`. If it appears in the list, proceed to drop it.
DROP PROCEDURE IF EXISTS your_stored_procedure_name;
2
Recreate the stored procedure by running its `CREATE PROCEDURE` statement.
CREATE PROCEDURE your_stored_procedure_name(...) BEGIN
-- Your procedure logic here
END;
3
After recreating, attempt to call the stored procedure again.
CALL your_stored_procedure_name();