I'm receiving the following error when trying to create a function in mySQL 5.1:
Error Code : 1064 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 25 (0 ms taken)
Here is my code:
DELIMITER $$
CREATE
FUNCTION removeMethodAndBackslash(input VARCHAR(40))
RETURNS VARCHAR(20)
BEGIN
DECLARE loginName VARCHAR(40);
SET loginName = input;
IF SUBSTRING(loginName,7) LIKE '\b%' THEN
SET loginName = 'b' + SUBSTRING(input,8);
ELSE IF SUBSTRING(loginName,7) LIKE '\n%' THEN
SET loginName = 'n' + SUBSTRING(input,8);
ELSE IF SUBSTRING(loginName,7) LIKE '\t%' THEN
SET loginName = 't' + SUBSTRING(input,8);
ELSE IF SUBSTRING(loginName,7) LIKE '\r%' THEN
SET loginName = 'r' + SUBSTRING(input,8);
ELSE
SET loginName = SUBSTRING(input,7);
RETURN loginName;
END $$
DELIMITER ;
I've been playing with the syntax for a while and I'm certain its a very small detail that I'm overlooking. Any help would be greatly appreciated.