标签:done value int 存储过程 repeat ace roc 定义变量 not found
delimiter // drop procedure if exists save; CREATE PROCEDURE save() BEGIN -- 定义变量 DECLARE a VARCHAR(1000); DECLARE b VARCHAR(1000); DECLARE c VARCHAR(1000); declare done int default 0; -- 创建游标,并存储数据 DECLARE cur_test CURSOR FOR SELECT id as id ,REPLACE ( JSON_EXTRACT (data_json, ‘$.domination‘), ‘"‘, ‘‘ ) AS domination, REPLACE ( JSON_EXTRACT (data_json, ‘$.dominationCn‘), ‘"‘, ‘‘ ) AS dominationCn from t_eliminate where domination IS NULL ; -- 游标中的内容执行完后将done设置为1 DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; -- 打开游标 open cur_test; -- 执行循环 REPEAT FETCH cur_test into a,b,c; -- 判断是否结束循环 IF not done THEN -- 取游标中的值 -- INSERT into aaa(did) values(a); -- 执行更新操作 UPDATE t_eliminate set domination = b,domination_cn=c where id = a; end if; until done END repeat; -- 释放游标 CLOSE cur_test; END; // CALL save();
标签:done value int 存储过程 repeat ace roc 定义变量 not found
原文地址:https://www.cnblogs.com/woshishanshan/p/12463370.html