Hi there, I am trying to set up a simple stored procedure that creates a table (the name of which i will provide) from a simple SELECT against another table. Whilst the procedure seems to be accepted in ok when I enter it, when I call it, providing a table name it gives me a syntax error, see below
mysql> DELIMITER //
mysql> CREATE PROCEDURE testproc(IN param1 varchar(20))
-> BEGIN
-> SET @s = CONCAT('DROP TABLE IF EXISTS ', param1);
-> PREPARE stm FROM @s;
-> EXECUTE stm;
-> SET @s = CONCAT('CREATE TABLE ', param1 , 'ENGINE=MEMORY SELECT * FROM `general`');
-> PREPARE stm FROM @s;
-> EXECUTE stm;
-> END//
Query OK, 0 rows affected (0.00 sec)
Now when I call it
mysql> DELIMITER ;
mysql> call testproc("test321");
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=MEMORY SELECT * FROM `general`' at line 1
Is there something basic im doing wrong here?