MySQL Forums
Forum List  »  Partitioning

Re: ERROR 1564 on YEAR() function
Posted by: Stefan Reimers
Date: December 27, 2008 06:05AM

Hey,

thanks Mattias. I successfully transferred the logic. Here are the working results:

DELIMITER //
CREATE DEFINER=root EVENT
yearly_partition
ON SCHEDULE
EVERY 1 YEAR
STARTS '2008-12-31 23:30:00'
ON COMPLETION PRESERVE
DO
BEGIN
DECLARE pNameOld CHAR(5) DEFAULT CONCAT('p',YEAR(CURDATE()));
DECLARE pNameNew CHAR(5) DEFAULT CONCAT('p',YEAR(CURDATE())+1);
DECLARE sql_statement CHAR(143);
SET sql_statement = CONCAT('ALTER TABLE fact_something REORGANIZE PARTITION ',pNameOld,' INTO (PARTITION ',pNameOld,' VALUES LESS THAN (',YEAR(CURRENT_DATE),'), PARTITION ',pNameNew,' VALUES LESS THAN MAXVALUE)');
SET @sql_prepare = sql_statement;
PREPARE query FROM @sql_prepare;
EXECUTE query;
END//
DELIMITER ;

Options: ReplyQuote


Subject
Views
Written By
Posted
9359
December 07, 2008 08:50AM
4113
December 11, 2008 08:24AM
Re: ERROR 1564 on YEAR() function
3629
December 27, 2008 06:05AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.