I have several triggers that activate a procedure, I want to identify the table that uses the trigger and use it as a variable to a procedure.

Another option is to pass a variable (the name of the table) from a trigger to a procedure

Is it possible in mysql > 5.7?

I try not to create many procedures, I want a single procedure that creates me other tables from the trigger variable.

What reserved MySQL variables should I use?


1 Answer 1


MySQL provides no way to do what you want.

The obvious suggestion would be to modify the triggers and the procedure to add one more parameter, which is the table name. But since it's obvious, you probably don't want to do so. Probably because the triggers and the procedure run in production, and they cannot be updated atomically (so if you modify the procedure first, triggers will fail; but if you modify a trigger first, it will fail).

If that it the reason, I suggest to use a user variable. In the triggers, you can do something like:

SET @table := 'wood_table';

And in the procedure, you will be able to check the value of @table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.