Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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.

share|improve this question

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.