Re: User and Timestamps

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Simon Heinrich <google(at)itrex(dot)de>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: User and Timestamps
Date: 2003-05-25 16:21:53
Message-ID: 20030525092101.R35205-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 22 May 2003, Simon Heinrich wrote:

> Hi NG,
>
> working with postgres is very intresting...for a newby like me a big
> big playground and so I found a nother toy which i like to handle :)
>
> Rules or Triggers + Functions
>
> In all of the maintable in my DB I have the following Fields:
>
> created timestamptz
> createdby vchar(15)
> modified timestamptz
> modifiedby vchar(15)
>
> Now I like to setup a mechanismus which tke care of inserts and
> updates. Everytime an insert is calld created shuld stamped whith the
> current loggedin user and createdby whith Current_Timestamp....Same
> for update whith modifed and modifedby.
>
> I tried to set up a rule but it wont work because I find no way to
> identify the newly inserted row :(

You'll probably be happier with a before trigger than a rule. The trigger
functions should be pretty simple in plpgsql.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2003-05-25 16:26:49 Re: Transaction Triggers!
Previous Message Bruno Wolff III 2003-05-25 13:48:33 Re: pg_dump and data consistency in the backup