hello everyone,
MYSQL query ............
how to set prepare stmt result in variable
i have written prepare stmt in store procedure and i want to set result of prepare stmt in variable
i am passing table name as a parameter to procedure because the tables are generated dynamically after every month (that kind of script is written on linux OS). so the table name is not fix.Code:CREATE PROCEDURE `sp_countrows`(in_table_name varchar(30)) READS SQL DATA BEGIN SET @s = CONCAT('SELECT sum(QuotaUsage) AS "', in_table_name, '(QTY)" FROM ', in_table_name); PREPARE stmt FROM @s; EXECUTE stmt; END



Reply With Quote
Bookmarks