Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: column: on update update?



CZUCZY Gergely <gergely(dot)czuczy(at)harmless(dot)hu> writes:
> I'd prefer this version:
> CREATE FUNCTION awlupdate RETURNS TRIGGER AS '
> BEGIN
>   NEW.lastupdate = now();
>   RETURN NEW;
> END' LANGUAGE plpgsql;

> CREATE TRIGGER... the same.

No, the trigger command has to be BEFORE UPDATE not AFTER UPDATE for
this to work.  This is definitely the better way though because the
row only gets updated once, not stored and then updated again
(in fact, I think you could get into an infinite loop if an AFTER
UPDATE trigger tries to update the row again).

			regards, tom lane



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group