当前位置:Gxlcms > 数据库问题 > MySql 游标

MySql 游标

时间:2021-07-01 10:21:17 帮助过:18人阅读


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 游标

标签:cal   var   etc   efault   最大   set   for   mysql   next   

人气教程排行