Received: from bologna.nettuno.it (bologna.nettuno.it [193.43.2.1]) by hub.org (8.8.8/8.8.8) with ESMTP id JAA16427 for ; Mon, 21 Sep 1998 09:53:56 -0400 (EDT) (envelope-from sferac@bo.nettuno.it) Received: from proxy.sferacarta.com (mail@sfcabop1.nettuno.it [193.207.10.213]) by bologna.nettuno.it (8.8.6/8.8.6/NETTuno 3.1) with ESMTP id PAA00169; Mon, 21 Sep 1998 15:53:53 +0200 (MDT) Received: from blu.sferacarta.com (mail.sferacarta.com) [10.20.30.12] by proxy.sferacarta.com with smtp (Exim 1.92 #1 (Debian)) id 0zL8B6-0004tS-00; Mon, 21 Sep 1998 15:47:04 +0000 Date: Mon, 21 Sep 1998 15:53:51 +0200 From: Sferacarta Software X-Mailer: The Bat! (v1.017) UNREG Reply-To: Sferacarta Software Organization: Sferacarta Software Priority: Normal Message-ID: <1662.980921@bo.nettuno.it> To: pgsql-sql@postgresql.org, "Detlef Boddin S/N O.21" Subject: Re: [SQL] Q:Update Rule References: <360623CF.DD9A03E1@teleport.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit 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'