DROP PROCEDURE IF EXISTS board_log_arrange_test;
delimiter;;
CREATE PROCEDURE board_log_arrange_test()
BEGIN
-- setup
DECLARE stmt varchar(2000) default @stmt;
DECLARE partitiontodrop varchar(64);
DECLARE v_max_partno varchar(10);
DECLARE v_max_value int(10);
select concat('p',(replace(max(partition_name), 'p', '')+1)) into v_max_partno
from information_schema.partitions as party
where table_name = 'board_log_test' ;
select max(partition_description)+1000000 into v_max_value
from information_schema.partitions
where table_name = 'board_log_test';
-- Find and drop the first partition in the table.
SELECT partition_name
INTO partitionToDrop
FROM INFORMATION_SCHEMA.PARTITIONS
WHERE table_schema='board'
AND table_name='board_log_test'
AND partition_ordinal_position=1;
SET @stmt = CONCAT('ALTER TABLE board_log_test DROP PARTITION ' , partitionToDrop);
PREPARE pStmt FROM @stmt;
EXECUTE pStmt;
DEALLOCATE PREPARE pStmt;
-- Add a new partition using the input date for a value limit.
SET @stmt = CONCAT('ALTER TABLE board_log_test ADD PARTITION (PARTITION ', v_max_partno, ' VALUES LESS THAN (',v_max_value,')');
PREPARE pStmt FROM @stmt;
EXECUTE pStmt;
DEALLOCATE PREPARE pStmt;
-- Cleanup
SET @stmt = stmt;
END;;
DELIMITER ;
-------------------------------------------------------------------------------------------------------------------------------
위의 프로시져 실행시
Lookup Error - MySQL Database Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
다음의 에러 메시지가 뜨는데 어디를 교처야 할지 고수님들 도움 부탁드립니다!!!
원인 찾았습니다!!!
-- Add a new partition using the input date for a value limit.
SET @stmt = CONCAT('ALTER TABLE board_log_test ADD PARTITION (PARTITION ', v_max_partno, ' VALUES LESS THAN (',v_max_value,')');
위에서 뒤에 ) 하나가 빠졌었네요
-- Add a new partition using the input date for a value limit.
SET @stmt = CONCAT('ALTER TABLE board_log_test ADD PARTITION (PARTITION ', v_max_partno, ' VALUES LESS THAN (',v_max_value,'))');