Mysql PREPARE
and EXECUTE
statements can not be used in a stored procedure that is being called by a trigger. The result would be Error Code: 1336. Dynamic SQL is not allowed in stored function or trigger
.
Does anyone know a plausible work around to this?
You can't run
PREPARE
/EXECUTE
from inside aTRIGGER
, but you can from anEVENT
(if you are running MySQL 5.5 or greater).Here's an example of running
PREPARE
/EXECUTE
from anEVENT
:Then running this:
will produce this output:
If you don't want to use an
EVENT
, or wait the second or so for it to fire, you could add aCALL proc()
after every command that would cause aTRIGGER
to fire.