I'm trying to get some stored procedures to fire from a MySQL 5.1 trigger. When these were called without triggers, I used prepare and execute statements to build queries and other SQL calls. I have a servies of statements like these:
select concat("select ", $var1, " from ". $var2, " where col1 = ", $var3) into @sql; prepare s1 from @sql; execute s1;
Clearly that approach won't work with code involved in a trigger as prepared statements aren't allowed in triggers or the procedures they call. I'm looking for some alternative ideas about how to build statements like these and execute them without using dynamic SQL. I've thought about nested case statements and similar structures, but $var1 and $var3 could have any of hundreds of values.
Has anyone found a way to do this? Googling hasn't been much help.