Home > database > MYSQL custom function at 1064 fault
MYSQL custom function at 1064 fault
Time:09-27
Do you want to be a string segmentation custom function, the result is always an error, please help to look at, thank you!
CREATE function GetCharIndexNum (` @ findstring ` varchar (255), ` @ string ` varchar (255)) Returns the int
The BEGIN Declare ` @ location ` int. Declare ` @ num ` int.
The set @ num=0; The set @ location=charindex (@ findstring, @ string); While @ the location & gt; 0 do The begin The set @ num=@ num + 1; Set @ string=the substring (@ string, @ location + 1, len (@ string)); The set @ location=charindex (@ findstring, @ string);
End Return the @ num
END
CodePudding user response:
Delimiter/ . Your function to create statement (note: your statement "return @ num" missing semicolon ";"