By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,887 Members | 1,150 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,887 IT Pros & Developers. It's quick & easy.

Problem is not solved yet (Re:-prepare stmt)

P: 7
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

Expand|Select|Wrap|Line Numbers
  1.   CREATE PROCEDURE `sp_countrows`(in_table_name varchar(30))
  2.   READS SQL DATA
  3.   BEGIN
  4.   SET @s = CONCAT('SELECT sum(QuotaUsage) AS "', in_table_name, '(SUM)" FROM ', in_table_name);
  5.   PREPARE stmt FROM @s;
  6.   EXECUTE stmt;
  7.   END
  8.  
-----------------------------------------------------------------------------------------
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.
Nov 28 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.