Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9129043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:39:26+00:00 2026-06-17T07:39:26+00:00

how can I rewrite the following SP to face recursive limitation in MySQL: CREATE

  • 0

how can I rewrite the following SP to face recursive limitation in MySQL:

CREATE DEFINER = `root`@`localhost` PROCEDURE `SP_DeleteParentDirectory`(pParentID INT,pIsFolder INT,pReferenceID INT)
BEGIN   
SET @@SESSION.max_sp_recursion_depth = 255;
    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  filesinfo.IsFolder,filesinfo.ReferenceID INTO @IsFolder,@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;
    DELETE FROM filesinfo Where  filesinfo.FileID= pParentID;
    IF EXISTS( SELECT  * FROM  filesrefrences WHERE filesrefrences.ReferenceID = pReferenceID AND filesrefrences.RefrenceCount>1) THEN
            UPDATE filesrefrences
            SET RefrenceCount= RefrenceCount-1 WHERE  filesrefrences.ReferenceID = pReferenceID;            
    ELSE            
            SET @ReferenceKey= NULL;
            Select filesrefrences.RefrenceKey INTO @ReferenceKey FROM filesrefrences WHERE filesrefrences.ReferenceID= pReferenceID;
            IF NOT EXISTS(SELECT * FROM deletefilesreferences WHERE deletefilesreferences.FileReference= @ReferenceKey) THEN
            INSERT INTO deletefilesreferences (deletefilesreferences.FileReference)VALUES(@ReferenceKey);
            END IF;
            DELETE FROM filesrefrences where filesrefrences.ReferenceID = pReferenceID;         
    END IF;
    -- CALL SP_DeleteFileInfo(pParentID,pReferenceID);      
    -- SELECT * FROM deletefilesreferences;
    -- CALL SP_GetDeletedReferences();
END;

without using this sts :

“SET @@SESSION.max_sp_recursion_depth = 255;”
I mean that can interact with hierarchy data without recursion.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:39:27+00:00Added an answer on June 17, 2026 at 7:39 am

    Mysql allows up to 255 recursion in a PROCEDURE if you set max_sp_recursion_depth.

    Its risky because there is a chance that the needed recursion depth may exceed 255 sometime in future.

    So Its better you replace your function with a procedure, using an INOUT variable for the return_result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I rewrite he following code using C#3.0 automatic properties? private int _myValue;
How can I rewrite the following urls in CodeIgniter localhost/users/show_profile/john to localhost/john Thanks
How can I rewrite the following codeigniter url localhost/test_project/pages/show_page/11 to localhost/test_project/pages/11 and is it
How can I rewrite following clause: if u'января' in date_category['title']: month = 1 elif
how I can rewrite this: for (int i = 0; i < numberOfSpaces; i++)
How can I rewrite the for loop in the following piece of code using
I am trying to rewrite the following statement from Coffeescript to Javascript: d.data.name[0..1].toLowerCase() Can
How I can rewrite following query that I will take minus Correction and Used
How can I rewrite the following CURL command, so that it doesn't use the
I'm using the following rewrite rule, but I can't get it to work: RewriteRule

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.