MySql 游标
Posted leon&kobe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySql 游标相关的知识,希望对你有一定的参考价值。
create procedure delWord_activety()
BEGIN
DECLARE Done INT DEFAULT 0;
DECLARE v_id VARCHAR(50);
DECLARE v_content text;
DECLARE f_content text;
/*声明游标*/
DECLARE rs CURSOR FOR SELECT id,content FROM cms_activity_data_121;
/*异常处理*/
DECLARE CONTINUE HANDLER FOR SQLSTATE ‘02000‘ SET Done=1;
/*打开游标*/
OPEN rs;
/*逐个取出当前记录LingQi字段的值,需要进行最大值的判断*/
FETCH NEXT FROM rs INTO v_id,v_content;
/*遍历数据表*/
REPEAT
IF NOT Done THEN
set v_content=replace(v_content,char(10),‘‘);
set v_content=replace(v_content,char(13),‘‘);
update cms_activity_data set content=v_content where id=v_id;
END IF;
FETCH NEXT FROM rs INTO v_id,v_content;
UNTIL Done END REPEAT;
/*关闭游标*/
CLOSE rs;
end
DROP PROCEDURE delWord_activety
call delWord_activety()
以上是关于MySql 游标的主要内容,如果未能解决你的问题,请参考以下文章