Я пытаюсь получить триггер для обновления значения строки текущей отметкой времени, и эта же отметка времени используется в таблице, которая вставляется этим триггером.Триггер работает с set new.last_update = 'some constant', но в тот момент, когда вы добавляете переменную или выбираете все, что я получаю, это нулевые значения в строке.
drop trigger if exists event_update_history;
delimiter //
create trigger event_update_history before update on Events
for each row
begin
declare history_timestamp timestamp;
set @history_timestamp = timestamp(unix_timestamp());
if (new.current_state <> old.current_state) then
insert into Event_History (evt_id, evt_state, time_of_change, userid) values (new.evt_id, new.current_state, history_timestamp, new.last_updated_by);
end if;
set new.last_update = history_timestamp; ## THIS IS THE PART THAT IS NOT WORKING but works if you send a constant
end; //
delimiter ;