Error writing database log record

0

I have a database with MySQL. I am doing the log of this database. Most are working, but I can not get the registry id that has been modified.

Example : When changing some data, it should be saved in the log id of the record that was changed, but only NULL appears. I'm doing them using 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);

How do I make sure that the id of the data is saved in the logs?

    
asked by anonymous 06.11.2015 / 12:51

1 answer

1

It seems that only the padding is wrong, it would be something like this (it depends on what you want to write and how you will arrange the log ):

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.Id, NOW(), 'insert', @usuario);
    
07.11.2015 / 03:17