I am trying to set a trigger to record a timestamp in a log table when the main table is updated. I have a main table called cm and have a log table with a timestamp column.
The timestamp column in the log table is set up as follows:
ALTER TABLE log ADD COLUMN modified_timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
The trigger I trying is as follows but throws this error “Error Code 1193. Unknown system variable ‘modified_timestamp’
Trigger:
DELIMITER //
CREATE TRIGGER `ahrq cm`.`table_timestamp` BEFORE UPDATE ON `ahrq cm`.`ahrq_inventory_all`
FOR EACH ROW begin
set log.modified_timestamp=CURRENT_TIMESTAMP();
end
//
Can anyone shed light on this error?
Your trigger should update the
logtable using a normal SQL command: