470,604 Members | 2,226 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,604 developers. It's quick & easy.

Dynamically construct and execute SQL in StoredProcedure

Hey!

I need to dynamically create an SQL statement within a MySQL 5.0.20
stored procedure.

-- PSEUDO CODE
create procedure DynSQLTest
(
in sTable varchar(45)
)
begin
declare sSQL varchar(45);

select Concat('select * from ',sTable,' where ...) into sSQL;

EXECUTESQL(sSQL);
end;

Is there a possibility to construct the SQL in a varchar and then
execute it? I spent some time googling but did not find anything.

Thank you for any help!

Fred
Apr 24 '06 #1
1 1485
Fred wrote:
Is there a possibility to construct the SQL in a varchar and then
execute it? I spent some time googling but did not find anything.


See here:
http://dev.mysql.com/doc/refman/5.0/en/sqlps.html

You can do this in stored procedures. See example in this article:
http://dev.mysql.com/tech-resources/...toredproc.html

Regards,
Bill K.
Apr 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jeff Thur | last post: by
4 posts views Thread by Dikkuuhh | last post: by
7 posts views Thread by mirandacascade | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.