Unable to create UDF. Am getting below error at the time of creation
Error: 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 ';
CREATE FUNCTION `seat_count`(seatno varchar(250))
RETURNs varchar(250)
BEG' at line 1
code: http://pastebin.com/uf4DkXZh
code:
CREATE FUNCTION `seat_count`(seatno VARCHAR(250))
RETURNS VARCHAR(250)
BEGIN
SET @str= REPLACE(seatno, ',', '');
SET @stcnt=CHAR_LENGTH(str);
SET @x=1;
SET @result;
WHILE (@x <= @stcnt)
DO
SET @st=SUBSTRING_INDEX(@str,',',X);
IF ((LENGTH(@seatno) - LENGTH(REPLACE(@seatno, st, '')))/LENGTH(@st)=1)
THEN SET @result=CONCAT(@st,@result);
END IF;
SET @x=@x+1;
END WHILE;
RETURN @result;
END$$