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
-----------------------------------------------------------------------------------------
Atli
Moderator
So you want to use the results of the query in the procedure?
If so, you should look into Cursors.
-----------------------------------------------------------------------------------------
pankaj
newbie
can u explain me with example. I haven't used the cursor yet.
I am new in mysql.
so please tell me with example how to get the prepare stmt result using cursor........
I have seen example of cursor in mysql site. but they haven't used the prepare stmt.
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.
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
Code:
CREATE PROCEDURE `sp_countrows`(in_table_name varchar(30))
READS SQL DATA
BEGIN
SET @s = CONCAT('SELECT sum(QuotaUsage) AS "', in_table_name, '(SUM)" FROM ', in_table_name);
PREPARE stmt FROM @s;
EXECUTE stmt;
END
Atli
Moderator
So you want to use the results of the query in the procedure?
If so, you should look into Cursors.
-----------------------------------------------------------------------------------------
pankaj
newbie
can u explain me with example. I haven't used the cursor yet.
I am new in mysql.
so please tell me with example how to get the prepare stmt result using cursor........
I have seen example of cursor in mysql site. but they haven't used the prepare stmt.
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.