This
CREATE FUNCTION getTagID(tag VARCHAR(100)) RETURNS BIGINT
BEGIN
DECLARE tagID BIGINT;
SET tagID = (SELECT id FROM tags WHERE text = tag);
IF tagID IS NULL
THEN
(INSERT INTO tags (text) VALUES (tag));
SET tagID = (SELECT LAST_INSERT_ID());
END IF;
RETURN tagID;
END
fails with
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4
Why?
This function is related to the problem here: