Regularly update the value status of table field columns (Stored Procedure + scheduled task)

Source: Internet
Author: User

The value status (Stored Procedure + scheduled task) of the regularly updated table field column now has two more tables, tcm and doc; db_count: id count1 2202 3003 2204 2225 240db_date: id t_date count 1 17:04:07 2202 15:04:07 2243 11:04:07 2254 17:04:07 3005 10:04:07 5006 --- stored procedure change db_count table count value is 0; DELIMITER // create procedure update_count () begin declare m date; DECLARE y CURSOR for select t_date from db_date; declare continue handler for sqlstate '100' SET k = 1; OPEN y; FETCH y INTO m; if sysdate ()> m THENUPDATE db_date t, db_count g SET g. count = 0 WHERE t. id = g. id; end if; CLOSE y; END // DELIMITER; ---- event. The event interval is 1 second, execute this event delimiter // create event my_countON schedule every 1 second dobegincall update_count (); end // DELIMITER; select * from db_count;

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.