how to use mysql_How to use recursive in mysql.

I have a trouble about recursive in mysql. the key is I use mysql not long time. I don't know much about MySql.So it is a big trouble of me.

Ok, go to the business now. If you want to use recursive in mysql,you need to do the three step first:

1. Open your mysql config file from the mysql installation location.

2. Set the recursive depth to the max value:

max_sp_recursion_depth=255

3. Set thread stack size:        thread_stack=64M    I  don't know how much size of the thread_stack is logical,but the value of the thread_stack is worked.

there is my script:

CREATE DEFINER = 'root'@'localhost' PROCEDURE `proc_GetCategoryRecursive`(

cid int

)

NOT DETERMINISTIC

CONTAINS SQL

SQL SECURITY DEFINER

COMMENT ''

begin

declare curid int;

insert into tblCategory (categoryid)

select id from productcategory where  parentid=cid and isdetail=true;

insert into tblUndetail (categoryid)

select id from productcategory where  parentid=cid and isdetail=false;

WHILE EXISTS(select * from tblundetail ) do

select categoryid into curid from tblundetail limit 1;

delete from tblundetail where categoryid=curid;/*Don't forget delete the current record before invoke recursive*/

call proc_GetCategoryRecursive(curid);

end while;

end;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值