1 DROP PROCEDURE UpdateImgURL; 2 /***游标***/ 3 CREATE PROCEDURE UpdateImgURL() 4 BEGIN 5 -- 遍历数据结束标志 6 DECLARE Done INT DEFAULT 0; 7 DECLARE Imgurl CHAR(255) DEFAULT ""; 8 -- 游标 9 DECLARE RS CURSOR FOR SELECT imgurl FROM weixin_linkface_userinfo ; 10 -- 异常处理 11 DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET Done = 1; 12 -- 打开游标 13 OPEN RS; 14 FETCH NEXT FROM RS INTO Imgurl; 15 REPEAT 16 IF NOT Done THEN 17 /**update 表名 set 字段名=REPLACE (字段名,'原来的值','要修改的值') where 条件 **/ 18 END IF; 19 FETCH NEXT FROM RS INTO Imgurl; 20 UNTIL Done END REPEAT; 21 CLOSE rs; 22 END 23 /**执行存储过程**/ 24 CALL UpdateImgURL
批量修改某表对应字段的值。