I have a table that has 3 columns. One is a record, one is created_time, and the last one is updated_at. I want to create a stored procedure that changes updated_at to NOW() when a record is UPDATED. Each row also has an id called id. I don't have any initial code to show as I am slightly confused on how triggers work. I understand that my trigger would be an update or record, but how do I tell the table to update its corresponding updated_at value to NOW().
I created my table as such:
CREATE TABLE keyvalue (
id id,
record VARCHAR(128) UNIQUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
PRIMARY KEY(id)
);
Any help would be appreciated.