473,326 Members | 2,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

how to set result of prepare stmt (MYSQL)

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
Nov 26 '08 #1
2 4459
Atli
5,058 Expert 4TB
So you want to use the results of the query in the procedure?

If so, you should look into Cursors.
Nov 26 '08 #2
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 26 '08 #3

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

Similar topics

4
by: Thierry B. | last post by:
Hi, Here is my query, ran from oracle sql*plus: SELECT mrbs_room.id, start_time, end_time, name, mrbs_entry.id, type FROM mrbs_entry, mrbs_room WHERE mrbs_entry.room_id = mrbs_room.id...
3
by: Randy Rodent | last post by:
I have a problem with some SQL code that can be run at the mySQL command prompt, and in PHP, I can prepare it with no problem, but I get a syntax error when I try and exexute it. $sql = <<< EOF...
1
by: Todd Peterson | last post by:
I'm a newbie to DB2 and am trying to figure out how to write a stored procedure, using dynamic SQL statements to return a result set. I believe the majority of the hurdles I have been facing might...
2
by: claus.hirth | last post by:
I wrote a stored procedure that uses a prepared INSERT INTO statement in order to play with the PREPARE and EXECUTE keywords. In transcript 1 below the call to that stored procedure does not...
10
by: elliottjeff | last post by:
I was wondering if there is a way to create a stored procedure that I can DECLARE Variables then set these variables using a select statment -- up to here works. then use a different statement...
0
by: situ | last post by:
hi, i'm trying to return a result set from a procedure using i series navigator. how ever i am getting the results back but with warning as below. Message: 1 result sets are available from...
1
by: Purple-D | last post by:
Hi All, I came across a weird situation today. We have a simple sql statement with some java code thrown around it which executes in about 1-2 seconds. However when put in input parameter...
1
by: Akino877 | last post by:
Hello, I have a small Perl program : #!/usr/bin/perl -w use DBI; use Mysql; $host = ""; $database = ""; $user = "root";
2
by: akbarmahrat | last post by:
i want to convert this mysql code into mssql. SET strSTMTDEFINATION = Concat(SUBSTRING(strSTMTDEFINATION,1,LENGTH(strSTMTDEFINATION) -1),");"); SET @myCREATE := strSTMTDEFINATION;...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.