I wrote a stored procedure. It works fine, except that the table name is an input parameter.
Let's see my proc in MySQL:
DELIMITER $$ USE `db_test`$$ DROP PROCEDURE IF EXISTS test_proc$$ CREATE DEFINER=`root`@`localhost` PROCEDURE `test_proc`(IN serviceName VARCHAR(10),IN newsInfoTable VARCHAR(100)) BEGIN SELECT COUNT(*) FROM newsInfoTable WHERE newsServiceName=serviceName; END$$ DELIMITER ;
Parameters of the stored procedure call:
USE db_test; CALL test_proc('abc','tbl_test_news');
Here the service name parameter is working fine. But if I include the newsInfoTable variable as a table input parameter, then an error appears.
Table 'db_test.newsinfotable' does not exist
Why does this happen only for a table parameter? How can I extract from this error or
How to pass a table name to a stored procedure as a parameter?
source share