1

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?

Regards.

asked Feb 25, 2018 at 1:40

1 Answer 1

2

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.

answered Feb 25, 2018 at 2:44

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.