I understand what you are trying to do but if you look at performance this is going to create an overhead. Every call to the stored procedure is going to place information onto the stack call the stored procedure, dynamically generate the SQL, parse the statement and finally execute it.
If this is called once this will be negligible, however, if this is called many times then you could run into performance issues. You should access the data directly i.e. SELECT * FROM <tablename> rather than doing it through a stored procedure.
In any case, the code for creating this is:
Code:
DROP PROCEDURE IF EXISTS aProc;
DELIMITER $$
CREATE PROCEDURE aProc(tableName VARCHAR(30))
BEGIN
SET @s = CONCAT('SELECT * FROM ', tableName);
PREPARE stmt FROM @s;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
END
$$
DELIMITER ;