Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stored procedure does not exist, even after creating it

I am trying to create a mysql stored procedure . I have successfully created a procedure using the following code :

delimiter $$
CREATE PROCEDURE `myprocedure` (IN
 var1 DATE) 
BEGIN 
<---code--> 
END

And

SHOW CREATE PROCEDURE myprocedure

shows me the procedure I have created.

But the Call myprocedure(2011-05-31);

shows me the following error

#1305 - PROCEDURE db.myprocedure does not exist

db is database where I have created the procedure

What mistake am I doing?

Can anyone help me in this?

like image 747
ashu Avatar asked Jun 01 '11 10:06

ashu


People also ask

Could not find stored procedure I just created?

This error states “Could not find stored procedure 'GO'“. It simply means that the SQL Server could found the stored procedure with the name “GO“. Now, the main reason behind this error could be the misuse of the “GO” statement.

How do I enable a stored procedure in SQL?

Use SQL Server Management StudioExpand Databases, expand the database in which the procedure belongs, and then expand Programmability. Expand Stored Procedures, right-click the procedure to grant permissions on, and then select Properties.

Why stored procedure Cannot be called in function?

You cannot execute a stored procedure inside a function, because a function is not allowed to modify database state, and stored procedures are allowed to modify database state.


1 Answers

please check the following example paying particular attention to use of delimiters and quoting of date input parameters.

drop procedure if exists my_procedure;

delimiter #

create procedure my_procedure 
(
in p_start_date date
) 
begin

-- do something...
select p_start_date as start_date; -- end of sql statement

end# -- end of stored procedure block

delimiter ; -- switch delimiters again

call my_procedure('2011-01-31');

+------------+
| start_date |
+------------+
| 2011-01-31 |
+------------+
1 row in set (0.00 sec)
like image 117
Jon Black Avatar answered Oct 22 '22 15:10

Jon Black