Ted’s Blog

‘delimiter’ doesn’t work when ’source’ from other files

2006-1-10 2:52 pm

MySQL starts support stored procedure from 5.0. It requires use ; to delimite statements between ‘BEGIN’ and ‘END’ block. So, typically you wrong your stored proc lik

delimiter //
CREATE PROCEDURE foo()
BEGIN
SELECT 'Hello World!';
END
//
delimiter ;

Unfortunately, it WON”T work if your source the script :-(

It turns out to be a bug
MySQL Bugs: #11523: \d behaves different from delimiter

The way to work around is to use ‘\d‘ instead of delimiter

\d //
CREATE PROCEDURE foo()
BEGIN
SELECT 'Hello World!';
END
//
\d ;

Care to comment?