MySQL Forums
Forum List  »  MySQL Workbench

Need Help in Creating a trigger for Autoupdate of timestamp
Posted by: Dinesh Ranghaswami
Date: August 17, 2015 02:36PM

Hi, I am trying to create a table with the below structure


KEY
DATA
CREATE_TIMESTAMP
LAST_UPDATE_TIMESTAMP

The timestamp value needs to be updated when everytime the row gets updated. So I am trying to create a trigger with the below code

CREATE TRIGGER `schemaname`.`triggername` AFTER UPDATE ON `tablename` FOR EACH ROW
BEGIN
SET tablename.LAST_UPDATE_TIMESTAMP = NOW();
END

I try to execute this in workbench but I am getting an error on this one.

ERROR 1193: Unknown system variable 'LAST_UPDATE_TIMESTAMP'
SQL Statement:
CREATE TRIGGER `schemaname`.`triggername` AFTER UPDATE ON `tablename` FOR EACH ROW
BEGIN
SET tablename.LAST_UPDATE_TIMESTAMP = NOW();
END

Options: ReplyQuote


Subject
Views
Written By
Posted
Need Help in Creating a trigger for Autoupdate of timestamp
1461
August 17, 2015 02:36PM


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.