How to Drop Procedure? I need to delete a stored procedure, but I'm getting an error message.

WaveLength's profile image WaveLength posted 6 days ago in General Permalink

After using a stored procedure, I wanted to use it again, so I ran this code:

UPDATE MyTable SET MyColumn = MyProcedure(MyColumn);

That worked, so I know the procedure exists.

Next, I wanted to drop the procedure, so I ran this:

DROP PROCEDURE MyProcedure;

But I got the following error message:

SQL Error (1305) MyProcedure does not exist.

Given that I can still use the procedure, it must exist, but when I try to delete it, HeidiSQL tells me the procedure does not exist.

Does it exist or not?

How can I delete the stored procedure?

Could the upper case letters in the name of my stored procedure be causing the trouble?

My HeidiSQL version is 12.8.0.6908 on Windows 11.

Thanks.

ansgar's profile image ansgar posted 5 days ago Permalink

If your routine returns a value - like in your case - it's most likely a function, not a procedure. So you would have to DROP FUNCTION mywhatever, not DROP PROCEDURE ....

You should be able to see the function in the database tab, or?

grafik.png

WaveLength's profile image WaveLength posted 5 days ago Permalink

Okay I tried that and it worked. Thanks.

One thing I found confusing was the message that appeared at the bottom:

DROP FUNCTION MyFunction; / / / Affected rows: 0 Found rows: 0 Warnings: 0 Duration for 1 query: 0.641 sec. /

So it seemed that the query had had no effect. Also, the function icon remained visible in the left panel. But when I refreshed the database, the icon disappeared. Evidently, the query did work.

Thanks for your help!

ansgar's profile image ansgar posted 4 days ago Permalink

Only a table contains rows, so it's very normal that 0 rows are affected when dropping a function.

HeidiSQL is not aware the function is already gone, so you need to refresh. When you drop the function per context menu in the database tab, HeidiSQL will remove it from the list immediately:

grafik.png

WaveLength's profile image WaveLength posted 4 days ago Permalink

Okay, thanks for your help!

Please login to leave a reply, or register at first.