pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sferacarta Software <sferac@bo.nettuno.it>
To: pgsql-sql@postgresql.org, "Detlef Boddin S/N O.21" <boddin@teleport.de>
Subject: Re: [SQL] Q:Update Rule
Date: Mon, 21 Sep 1998 15:53:51 +0200
Message-ID: <1662.980921@bo.nettuno.it> (raw)
References: <360623CF.DD9A03E1@teleport.de>

Hello Detlef,

lunedì, 21 settembre 98, you wrote:

DBSNO2>  I want  to save the user and date in a row when the user changed it.
DBSNO2> If I use an update rule, how can I prevent a loop ?

DBSNO2> Bad example:

DBSNO2> create rule  r_changed
DBSNO2>     as on update to requesttable
DBSNO2>     do update requesttable
DBSNO2>         set changed_by = current_user,
DBSNO2>                date_of_last_change = current_date;


DBSNO2> What is better ?

There's an example in the directory
pgsql/contrib/spi/insert_username.* that insert the
username when the user update or insert a row into the table.
I modified this example to insert CURRENT_USER and CURRENT_TIMESTAMP
into the row.
It is very sample to implement but if you want I may send it to you.

                        Jose'





view thread (2+ messages)

Message-ID: <1662.980921@bo.nettuno.it>
Permalink:  ../1662.980921@bo.nettuno.it/
Also on:    postgresql.org/message-id/1662.980921@bo.nettuno.it

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: sferac@bo.nettuno.it, boddin@teleport.de
  Subject: Re: [SQL] Q:Update Rule
  In-Reply-To: <1662.980921@bo.nettuno.it>
  References: <360623CF.DD9A03E1@teleport.de> <1662.980921@bo.nettuno.it>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox