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.