0
I have a database with Mysql. I am doing the log of this bank. Most are working, but I’m not able to get the id of the record that was modified.
Example: when changing some data, he should be saved in log the id of the registry that was changed, but only appears NULL
. I’m making them use triggers, and one of them is:
CREATE TRIGGER `empresa_AFTER_INS` AFTER INSERT ON `tabela` FOR EACH ROW
insert into `log`.`log_tabela`(campos_do_banco,data_hora,acao,usuario)
values (NEW.campos_do_banco,NOW(),'insert',@usuario);
Like I do so that the id
of the data be saved in the records of log?
Wouldn’t that be what you want?
values (OLD.Id, NOW(), 'insert', @usuario);
?– Maniero
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero