CREATE PROCEDURE update_dr_ytenantId()
BEGIN
DECLARE s INT DEFAULT 0;
DECLARE sql__ varchar(500);
DECLARE sqlList CURSOR FOR select concat('update ', a.TABLE_NAME, ' set ', ' dr = 0 where dr is null ; ') as sql_ from information_schema.`TABLES` a where a.table_name like 'hrcloud_staff_mgr_ext_%';
DECLARE CONTINUE HANDLER FOR NOT FOUND SET s = 1;
OPEN sqlList;
FETCH sqlList into sql__;
WHILE s <> 1 DO
SET @sql___ = sql__;
PREPARE stmt FROM @sql___;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
FETCH sqlList into sql__;
END WHILE;
CLOSE sqlList;
END;
|