Mysql Stored Function Parameter
I have just started to create a stored function this is my first time so I am having a few problems. Currently I call the function using SELECT test(); (test is the function name f
Solution 1:
Use:
DROPFUNCTION IF EXISTS `example`.`test` $$
CREATEFUNCTION `example`.`test` (param INT) RETURNSVARCHAR(32)
BEGINDECLARE new_username VARCHAR(32);
SELECT `username`
INTO new_username
FROM `users`
WHERE `ID` = param;
RETURNCOALESCE(new_username, 'Username not found');
END $$
Mind that the VARCHAR length of the RETURN value matches the variable, which should match the column length you want to return.
Post a Comment for "Mysql Stored Function Parameter"