Hi all,
I'm into writing a stored procedure which explodes a passed string by a passed delimiter and returns the n-th element of the result. n is passed too.
So this is what I came up with:
CREATE PROCEDURE SPLIT(IN strToSplit text, IN strDelimiter varchar(1), IN nPartToGet int,OUT strSlice varchar(255))
BEGIN
SET strSlice = replace(substring(substring_index(strToSplit, strDelimiter, nPartToGet),
length(substring_index(strToSplit,strDelimiter, nPartToGet - 1)) + 1), strDelimiter, '')
END
;
Sadly mysql keeps naging me that I've got an syntax error in there. IMHO this should work. Could anyone pls poke me on where I'm going wrong?
thanks in advance
K