thank You for your comment, it was usefull for me, because intially a have not found a way to exit from MySQL procedure on some conditions. But Your code is a little bit incorrect - this would be better ( at least Your code does not work on 5.0.18-nt ): -------- create procedure spMySproc(IN iParam INT) BEGIN sproc:BEGIN if iParam < 0 then leave sproc; end if; END; # sproc: END; END;
User Comments
This is very useful for exiting a stored procedure. (BTW this is not new, I found it today in several places and decided to add it here)
create procedure spMySproc(IN iParam INT)
sproc:BEGIN
if iParam < 0 then
leave sproc;
end if;
END
Note: If you get an error after adding the label, like with "start", pick a different word and see if the error goes away.
thank You for your comment, it was usefull for me, because intially a have not found a way to exit from MySQL procedure on some conditions.
But Your code is a little bit incorrect - this would be better ( at least Your code does not work on 5.0.18-nt ):
--------
create procedure spMySproc(IN iParam INT)
BEGIN
sproc:BEGIN
if iParam < 0 then
leave sproc;
end if;
END; # sproc: END;
END;
Add your own comment.