MySQL cursor loop example

Source: Internet
Author: User


MySQL cursor loop example if the in statement is used, it feels very slow and there is no result after running for a long time. You can grasp the progress by deleting the stored procedure. This is the sample code of MySQL cursor loop, avoid frequent searches and record them later. Www.2cto.com create definer = 'root' @ '%' PROCEDURE 'bi '. 'Clean _ data' () reads SQL DATABEGIN declare v_imei varchar (128); declare stop int default 0; declare cur cursor for (select imei from bi. tmp_imei); declare continue handler for sqlstate '000000' SET stop = 1; OPEN cur; FETCH cur INTO v_imei; WHILE stop <> 1 DO delete from bi. tmp_dt_fee_user_info where imei = v_imei; FETCH cur INTO v_imei; end while; CLOSE cur; 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.