CREATE SP_FOR_LOOP_SAMPLE(
OUT o_return INT
, OUT o_row_count INT
)
BEGIN
-- -------------------------------------
-- declare (BEGIN)
-- -------------------------------------
DECLARE v_abc VARCHAR(100) CHARSET utf8mb4 COLLATE utf8mb4_bin DEFAULT 'RemoveApiLogBatch';
-- -------------------------------------
-- declare (END)
-- -------------------------------------
SET ii = 0;
label1: WHILE ii < v_max_cnt DO
SET @query = CONCAT (
'DELETE FROM TEST_TABLE '
...
);
PREPARE stmt FROM @query;
EXECUTE stmt;
SELECT ROW_COUNT(), LAST_INSERT_ID() INTO @row_count, @last_insert_id;
DEALLOCATE PREPARE stmt;
IF @row_count < v_unit_cnt THEN
LEAVE label1; /* 종료 */
END IF;
SET ii = ii + 1;
END WHILE label1;
SET o_return = 0, o_row_count = @row_count;
END