MySQL Forums
Forum List  »  Triggers

Using tablename in trigger from system
Posted by: Wolfgang Ritter
Date: December 30, 2021 07:53AM

Hi

I am using a trigger to audit the transaction on my tables.

e.g. on my user table after an update i want to have following information, as my example shows.

CREATE DEFINER = CURRENT_USER TRIGGER `test`.`dbuser_AFTER_UPDATE`
AFTER UPDATE ON `dbuser`
FOR EACH ROW

BEGIN

INSERT INTO test_audit
SET type_of_action = 'u',
tablename = 'test.dbuser',
userid = new.userid,
ip4 = null,
ip6 = null,
longitude = null,
latitude = null,
time_stamp = NOW();

END

I want to use this trigger on all my tables and i would prefer to use system variable for the table name. Until now, i didn't found the name of the variable to replace my 'test.dbuser' with some kind of a system variable.

The only information i need is the name of the table, where my trigger is connected.

Does someone know the name or where i will find it.

Thanks
Wolfgang

Options: ReplyQuote


Subject
Views
Written By
Posted
Using tablename in trigger from system
535
December 30, 2021 07:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.