Dynamically construct and execute SQL in StoredProcedure - 04-24-2006 , 08:31 AM
I need to dynamically create an SQL statement within a MySQL 5.0.20
-- PSEUDO CODE
create procedure DynSQLTest
in sTable varchar(45)
declare sSQL varchar(45);
select Concat('select * from ',sTable,' where ...) into sSQL;
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!
Re: Dynamically construct and execute SQL in StoredProcedure - 04-24-2006 , 02:14 PM
You can do this in stored procedures. See example in this article: