Is there an error in this mysql stored procedure?

Source: Internet
Author: User
{Code...} code above, an error is reported in navicat
DELIMITER //create procedure largest_order(out largest_id int)BEGIN    declare this_id int;    declare this_amount float;    declare l_amount float default 0.0;    declare l_id int;    declare done int default 0;    declare c1 cursor for select orderid,amount from orders;    declare continue handler for SQLSTATE '02000' set done = 1;            open c1;    repeat         fetch c1 into this_id,this_amount;        if not done THEN            if this_amount > l_amount THEN                set l_amount=this_amount;                set l_id=this_id;            end IF;        end if;    until done end repeat;    close c1;    set largest_id = l_id;END//DELIMITER ;

The code above indicates that an error is reported in navicat.

Reply content:
DELIMITER //create procedure largest_order(out largest_id int)BEGIN    declare this_id int;    declare this_amount float;    declare l_amount float default 0.0;    declare l_id int;    declare done int default 0;    declare c1 cursor for select orderid,amount from orders;    declare continue handler for SQLSTATE '02000' set done = 1;            open c1;    repeat         fetch c1 into this_id,this_amount;        if not done THEN            if this_amount > l_amount THEN                set l_amount=this_amount;                set l_id=this_id;            end IF;        end if;    until done end repeat;    close c1;    set largest_id = l_id;END//DELIMITER ;

The code above indicates that an error is reported in navicat.

Fixed. There is a omission in the code, and a slash is missing at the end.

Related Article

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.