mysql 存储过程comment后面加参数报错(解决办法)

CREATE DEFINER=`root`@`%` PROCEDURE `yszx_addtest_columnComment`()
BEGIN

DECLARE t1 VARCHAR(32);
DECLARE t2 VARCHAR(32);
DECLARE t3 VARCHAR(255);
DECLARE a TEXT;
DECLARE s int DEFAULT 0;

DECLARE columns CURSOR FOR SELECT table_name, column_name FROM information_schema.columns
WHERE table_schema ='cenmds' AND (table_name LIKE 'yszx_qy%' OR table_name LIKE 'yszx_report%')
AND column_name != 'sys_id' AND column_name != 'requestSn' AND (column_comment IS null OR column_comment = '');

DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET s=1;
OPEN columns;
FETCH columns into t1,t2;
SELECT column_comment INTO t3 FROM yszx_col_to_comment WHERE column_name = t2 ORDER BY (id+0) DESC LIMIT 1;
while s <> 1 DO
set a = concat('ALTER TABLE ',t1,' MODIFY COLUMN ',t2,'VARCHAR(255) COMMENT ?');
PREPARE q from @a;
EXECUTE q using @t3;
DEALLOCATE PREPARE a;

FETCH columns into t1,t2;
end WHILE;

CLOSE columns;

END

posted @ 2020-12-18 18:16  听风的dog  阅读(840)  评论(0编辑  收藏  举报