I have a MYSQL FUNCTION. Can help you convert it to a MEMSQL FUNCTION OR MEMSQL PROCEDURE?


#1

Hello everyone

I have a MYSQL FUNCTION. Can help you convert it to a MEMSQL FUNCTION OR MEMSQL PROCEDURE?
Thank you

MYSQL FUNCTION:

CREATE  FUNCTION `TESTFUN`(Id INT) RETURNS varchar(4000)  

BEGIN
DECLARE sTemp VARCHAR (4000);
DECLARE sTempChd VARCHAR (4000);
SET sTemp = ‘$’;
SET sTempChd = cast(areaId AS CHAR);

WHILE sTempChd IS NOT NULL DO
SET sTemp = CONCAT(sTemp, ‘,’, sTempChd);
SELECT group_concat(id) INTO sTempChd FROM testtb WHERE FIND_IN_SET(parent_id, sTempChd) > 0;
END WHILE;
RETURN sTemp;
END


#2

MemSQL’s stored procedure language (MPSQL) only supports SQL statements in stored procedures, not functions. Depending on how you are using the function, you could do the equivalent with a stored procedure.