hi. i'm writing a procedure that retrives row count of any table (in a specific dataase). table name should be supplied as a parameter to the procedure.
i wrote:
--++++++++++++++++++++++++++++++++++++++++++++++++++++++
DROP PROCEDURE IF EXISTS getCount;
CREATE PROCEDURE getCount(IN tableName varchar(50), OUT rowCount int)
BEGIN
SELECT count(*) INTO rowCount FROM tableName;
END;
--++++++++++++++++++++++++++++++++++++++++++++++++++++++
when i call the procedure it says: table "tableName" does not exist, which means it does not recognizes "tableName" as a variable.
How can I persuade MySQL to accept it as a variable?!
Thanx for help.
i wrote:
--++++++++++++++++++++++++++++++++++++++++++++++++++++++
DROP PROCEDURE IF EXISTS getCount;
CREATE PROCEDURE getCount(IN tableName varchar(50), OUT rowCount int)
BEGIN
SELECT count(*) INTO rowCount FROM tableName;
END;
--++++++++++++++++++++++++++++++++++++++++++++++++++++++
when i call the procedure it says: table "tableName" does not exist, which means it does not recognizes "tableName" as a variable.
How can I persuade MySQL to accept it as a variable?!
Thanx for help.