DELIMITER $$
DROP PROCEDURE IF EXISTS memdb.mass_del_memarticle_2 $$
CREATE PROCEDURE memdb.`mass_del_memarticle_2`(
INOUT v_memid varchar(20)
)
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE v_counted_table VARCHAR(64);
DECLARE crsr CURSOR FOR SELECT table_name FROM memdb.article_list WHERE memid = v_memid AND STATUS = 1;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;
OPEN crsr;
read_loop: LOOP
FETCH crsr INTO v_counted_table;
IF done THEN
LEAVE read_loop;
END IF;
SET @s =
CONCAT(
'update article_list set cnt = (select count(*) from ',
v_counted_table,
" where mem_id = '",
v_memid,
"'", " and state = 'Y'",
" ) where table_name = '",
v_counted_table,
"';");
PREPARE stmt FROM @s;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END LOOP;
CLOSE crsr;
UPDATE article_list AS a
JOIN article_list AS b ON a.idx = b.idx
SET a.minus_point = a.point * b.cnt
where a.memid = v_memid;
END$$
DELIMITER ;
====================================================
위 프로시져에서 다른부분은 정상 작동하는데 close crsr; 이후에 나오는 쿼리인
UPDATE mass_del_article_list AS a
JOIN mass_del_article_list AS b ON a.idx = b.idx
SET a.minus_point = a.point * b.cnt
where a.memid = v_memid;
이부분의 업데이트문을 수행을 안하네요;;; 그부분에 다른 프로시져를 호출하게 해봐도 호출도 안합니다. 고수님들의 고견을 부탁드립니다! ㅠㅠ