Bug #3374 creating dynamic SQL strings within a stored proc
Submitted: 2 Apr 2004 13:48 Modified: 2 Dec 2005 17:53
Reporter: C L Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.0 OS:Windows (windows)
Assigned to: CPU Architecture:Any

[2 Apr 2004 13:48] C L
Description:
I intend to port a uer-intensive website(under dev.) to mysql.and I need to work on stored procedures.They look good but I do not have the capability to create and execute a dynamic SQL string in stored procs.
e.g
create proc test
begin
set @x=select 1 from pat'
exec (@x)
end

just like in sql server.

COuld you implement this ASAP.thanks v. much

How to repeat:
NA
[4 Nov 2005 10:39] Beat Vontobel
You can achieve this now via prepared statements:

PREPARE `query` FROM @query_string;
EXECUTE `query`;
DEALLOCATE PREPARE `query`;