MySQL Forums
Forum List  »  Stored Procedures

Re: prepared statement within stored procedure mysql
Posted by: Yurii Korotia
Date: September 30, 2012 02:02PM

DELIMITER $$

CREATE PROCEDURE auto_partition()
BEGIN

SET @l_SQL = CONCAT('ALTER TABLE tbl_location_history ADD PARTITION (PARTITION ',
'Part_Y', year( now( ) ) , '_M', month( now( ) ) , '_W', week( now( ))+1, ' VALUES LESS THAN (TO_DAYS(\'', DATE_FORMAT(date_add(NOW(), interval 15 day),'%Y-%m-%d'), '\')))');

PREPARE _stmt FROM @l_SQL;
EXECUTE _stmt;
DEALLOCATE PREPARE _stmt;

END$$

- - -

should work. not sure about @l_SQL and its ()

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: prepared statement within stored procedure mysql
3044
September 30, 2012 02:02PM


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.