This must be a pretty newbie mistake, but I'm still flummoxed by it. I created a very simple procedure:

create procedure deleteAll ()
delete from test1;
delete from test2;

but when I run it I get a Error code -1: Error executing SQL command.

The strangest part is that it still does what its supposed to, the data IS deleted from those two tables. So if its necessary I can go on with my life; but I would like to know why the error is occurring.



unfortunately and opposite to other database vendors, mysql does not publish a meaningful list of all error numbers or even warnings, they only explain some errors here and there. So one cannot found an explanation of "error" -1 what seems to be a negative SQLCODE (unfortunately there isn't an official standardized SQLCODE -1). Anyway, there are various reasons for such error:

You must have execute privilege if you want to execute procedure or function.

Are you owner of those tables, did you create them?

Are there any foreign keys related to one or both tables?

Maybe your tables are still locked? For example you have just inserted some data and auto commit is off then you would not allow to delete them. To unlock tables enter commit.

Ah, what version of mysql are you working with? You must have version 5.0.1 and up, eventually check proc table whether it exists.

Last but not least, the body of stored procedure is clasped by BEGIN .... END ; <--- ends with semicolon.