私は最初の手順を書いていますが、エラーが発生します。エラーを削除行に減らしましたが、理由はわかりません。誰かがここで問題を見つけることができますか?それは変数ですか?
DROP PROCEDURE IF EXISTS MPT_PROC;
DELIMITER $$
CREATE PROCEDURE MPT_PROC
MODIFIES SQL DATA
BEGIN
#-- DECLARE statements
DECLARE v_user_id INT DEFAULT 0;
DECLARE no_more_rows BOOLEAN;
DECLARE v_loop_cntr INT DEFAULT 0;
DECLARE v_num_rows INT DEFAULT 0;
DECLARE c_userfiles CURSOR
FOR
SELECT distinct f.user_id
FROM MPT_STG_FILEUPLOAD f
WHERE f.status = 'A'; #-- Accepted
DECLARE CONTINUE HANDLER FOR NOT FOUND
SET no_more_rows = TRUE;
OPEN c_userfiles;
#-- Loop through each user_id found as pending
the_loop: LOOP
FETCH c_userfiles INTO v_user_id;
#-- Break out of the loop if
#-- 1) there were no records, or
#-- 2) we've processed them all.
IF no_more_rows THEN
CLOSE c_userfiles;
LEAVE the_loop;
END IF;
DELETE FROM MPT_STG_FILEUPLOAD s
WHERE s.user_id = v_user_id;
COMMIT; #--Commiting the changes for this user
END LOOP the_loop;
END IF;
END
DELIMITER ;