Define search depth, user variables, etc.

Source: Internet
Author: User

The user variable is to be defined after the cursor, or it will be an error:


Right: After the cursor is defined, otherwise the error is incorrect.

DECLARE cur1 cursor FOR select a.id,a.topic_id from Diz_reply as a where a.topic_id=topicid and a.parent_id= ' 0 ';
DECLARE continue HANDLER for SQLSTATE ' 02000 ' set replyid=null;
Set @num = 0;


Define system variables, search for depth, define the cursor, or error:


The correct approach is:

DECLARE parent_id VARCHAR (32);
Declare cur1 CURSOR for SELECT a.id,a.topic_id,a.parent_id from Reply_test as a where a.parent_id=pid;
Declare CONTINUE HANDLER for SQLSTATE ' 02000 ' SET iid = null;
SET @ @max_sp_recursion_depth = 99;
if (layer>0) THEN

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.