create procedure all_joiner_message( in captions varchar(255), in contents text, in objectid int, in types int , out count int)
begin
declare userids int;
DECLARE _done INT DEFAULT 0;
DECLARE _Cur_Error CURSOR FOR
select a.userid from user_consum as a,sale as b where a.opobjectid=b.id and a.optype=types;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET _done = 1;
OPEN _Cur_Error;
REPEAT
FETCH _Cur_Error INTO userids;
IF NOT _done THEN
insert into usermail (userid,caption,content,readed) values (userids,captions,contents,0);
END IF;
UNTIL _done END REPEAT;
set count = row_count();
CLOSE _Cur_Error;
end;;
使用游标实现 mysql 存储过程中的循环
最新推荐文章于 2022-02-28 15:30:12 发布