Quantcast
Channel: MySQL Forums - MySQL Workbench
Viewing all articles
Browse latest Browse all 3724

Need Help in Creating a trigger for Autoupdate of timestamp (no replies)

$
0
0
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

Viewing all articles
Browse latest Browse all 3724

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>