BEGIN DECLARE IDS int; DECLARE permitstatus_s int; DECLARE b INT DEFAULT 0; DECLARE done INT DEFAULT 0; DECLARE cur_1 CURSOR FOR (SELECT t_asset_log_detail.ID as IDS FROM t_asset_log, t_asset_log_detail WHERE t_asset_log.ID = t_asset_log_detail.ASSET_LOG_ID AND (permitstatus = 0 or permitstatus is null) AND t_asset_log.OP_TYPE = 1); DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1; OPEN cur_1; REPEAT FETCH cur_1 INTO IDS; /* Get the first record */ IF NOT done THEN SELECT concat('myvar is ', IDS); update t_asset_log_detail set permitstatus=4 where ID=IDS; COMMIT; END IF; UNTIL done END REPEAT; CLOSE cur_1; end
Record the commonly used MYSQL stored procedures to modify the data cursor set
It is common to select a large number of result sets, and then the stored procedure updates some fields. It is very common,
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326565366&siteId=291194637
Recommended
Ranking