I am trying to write a simple stored procedure for insert with parameter as table name and insert value.
DELIMITER $$
DROP PROCEDURE IF EXISTS TEST3;
CREATE PROCEDURE TEST3(IN tab_name VARCHAR(40),IN IDVALUE VARCHAR(40))
BEGIN
SET @t2 = CONCAT('INSERT INTO ? (id) VALUES(?)');
PREPARE stmt4 FROM @t2;
EXECUTE stmt4 USING @tab_name, @IDVALUE;
DEALLOCATE PREPARE stmt4;
END $$
DELIMITER ;
It is being created but when I call it it throws following error:
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 '? (id) VALUES(?)' at line 1
What is that I am doing wrong.