Recursive stored functions in MySQL

后端 未结 2 1501
面向向阳花
面向向阳花 2020-12-09 13:01

I\'m trying to make a function that recursively builds a path for a specific category

CREATE FUNCTION getPath(inId INT)
RETURNS TEXT
DETERMINISTIC
BEGIN
             


        
2条回答
  •  清歌不尽
    2020-12-09 13:29

    MySQL does not allow recursive FUNCTIONs, even if you set max_sp_recursion_depth.

    It does allow up to 255 recursion in a PROCEDURE if you set max_sp_recursion_depth.

    So I recommend that you replace your function with a procedure, using an INOUT variable for the return_path.

提交回复
热议问题