I would remove the semicolon after END
.
...
END
|
DELIMITER ;
Re your comment, you can't use the current delimiter when declaring a new delimiter. That sounds confusing, but consider if you do this:
DELIMITER |;
Now MySQL would think the delimiter is "|;" (two characters, a pipe and a semicolon). If you think about it, DELIMITER
must be treated in a special way by the MySQL client. It's the only statement that can't be followed by the current delimiter.
So when setting the delimiter to pipe, do this:
DELIMITER |
When setting it back to semicolon, do this:
DELIMITER ;
FWIW, I ran the following with no error on my local test database on MySQL 5.0.75:
DROP FUNCTION IF EXISTS PersonName;
DELIMITER |
CREATE FUNCTION PersonName( personID SMALLINT )
RETURNS CHAR(20)
BEGIN
DECLARE pname CHAR(20) DEFAULT '';
SELECT name INTO pname FROM family WHERE ID=personID;
RETURN pname;
END
|
DELIMITER ;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…