I'm fairly new at writing triggers and function in postgres and i was wondering if this is the right way to go about it
Basically what i want it to do..is to update the last_update field (datetime) with the current date time whenever a row is accessed. Is this the right way to go about it?
Thanks in advance
CREATE FUNCTION troyupdate() RETURNS opaque AS '
BEGIN
UPDATE sessions SET sessions.last_update = now();
RETURN sessions;
END;
' LANGUAGE 'plpgsql';
CREATE TRIGGER "troytrigger" AFTER UPDATE ON "sessions" FOR EACH ROW EXECUTE PROCEDURE troyupdate();
Basically what i want it to do..is to update the last_update field (datetime) with the current date time whenever a row is accessed. Is this the right way to go about it?
Thanks in advance
CREATE FUNCTION troyupdate() RETURNS opaque AS '
BEGIN
UPDATE sessions SET sessions.last_update = now();
RETURN sessions;
END;
' LANGUAGE 'plpgsql';
CREATE TRIGGER "troytrigger" AFTER UPDATE ON "sessions" FOR EACH ROW EXECUTE PROCEDURE troyupdate();