更新:好的,我已经调试了这个问题,并发现通过执行
运行下面的递归存储过程时,我不断收到“递归限制0已被超过”的错误提示,即使我将其设置为
提前感谢您的帮助。
递归存储过程如下:
select @@max_sp_recursion_depth
,我可以看到变量设置为15,然而,当我用CALL single_limb_portfolio_list(xaccount_id, xparent_portfolio_id);
回调到它自己时,我收到了错误提示递归限制0已被达到,但它从未迭代过一次。
运行下面的递归存储过程时,我不断收到“递归限制0已被超过”的错误提示,即使我将其设置为
SET max_sp_recursion_depth = 15 ;
我是不是在错误的地方设置了这个变量?它的行为就像从未被设置过一样,总是保持为零?提前感谢您的帮助。
递归存储过程如下:
CREATE DEFINER=`aaron`@`localhost` PROCEDURE `single_limb_portfolio_list`(xaccount_id INT, IN portf_id_in INT, OUT str_portf_list VARCHAR(455))
BEGIN
DECLARE xportfolio_ID INT DEFAULT NULL ;
DECLARE xp_name INT DEFAULT NULL ;
DECLARE xparent_portfolio_id INT DEFAULT NULL ;
DECLARE xstr_list VARCHAR(455) ;
SET max_sp_recursion_depth = 15 ;
SELECT portfolio_id, p_name, parent_portfolio_id
FROM portfolio
WHERE account_id = xaccount_id
AND archived = 0
AND portfolio_id = portf_id_in
INTO xportfolio_ID, xp_name, xparent_portfolio_id;
IF xportfolio_ID IS NULL /* We have reached the top of the tree and there are no more parents for the portfolio list */
THEN
SET str_portf_list = xstr_list; #Set the full tree list to the variable that will be inserted as a row into the temp table previously created
ELSE
CALL single_limb_portfolio_list(xaccount_id, xparent_portfolio_id); #call the sproc with the next portfolio id to get the next parent id
SET xstr_list = concat(xp_name,"->",xstr_list); #Add the portfolio name to the overall portfolio list. Output like: "California -> Los Angelas"
END IF;
END