我在以下存储过程中使用递归
CREATE PROCEDURE `SP_DeleteParentDirectory`(pParentID INT,pIsFolder INT,pReferenceID INT)
BEGIN
SET @IsFolder= NULL;
SET @ChildID= NULL;
SET @ReferenceID= NULL;
IF ( pIsFolder= 2) THEN
SELECT FileID INTO @ChildID FROM filesinfo WHERE ParentID= pParentID LIMIT 1;
WHILE (@ChildID IS NOT NULL) DO
SELECT @IsFolder := filesinfo.IsFolder, @ReferenceID :=filesinfo.ReferenceID FROM filesinfo WHERE filesinfo.FileID = @ChildID;
CALL SP_DeleteParentDirectory(@ChildID,@IsFolder,@ReferenceID);
SELECT filesinfo.FileID INTO @ChildID FROM filesinfo WHERE ParentID= pParentID LIMIT 1;
END While;
END IF;
CALL SP_DeleteFileInfo(pParentID,pReferenceID);
END;;
但是当我尝试执行它时,我面临递归最大限制的错误,这迫使我添加以下语句:
SET @@SESSION.max_sp_recursion_depth = 100;
我可以在不添加此声明的情况下解决问题