MySQL-procedure 使用案例

创建存储过程
1
2
3
4
5
6
7
8
9
delimiter &&  
CREATE PROCEDURE clear_latest_enqueue_task(IN limit_task int(4))
BEGIN
DECLARE enqueue_latest_task_count int(4) default 0;
select count(*) as num into enqueue_latest_task_count from sogou_weixin_account_latest_article_crawl_task where enqueue_status = 1;
SET @current_enqueue_task = enqueue_latest_task_count ;
update sogou_weixin_account_latest_article_crawl_task set enqueue_status=0 where enqueue_status=1 and @current_enqueue_task >= limit_task;
END &&
delimiter ;
查看所有存储过程

show procedure status;

查看存储过程详细

show create procedure clear_latest_enqueue_task;