Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id OAA69855 for ; Fri, 22 Oct 1999 14:50:29 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id OAA21285; Fri, 22 Oct 1999 14:49:38 -0400 (EDT) To: Grant Kaufmann cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] Adding a rule to update a last_changed field In-reply-to: Your message of Fri, 22 Oct 1999 12:09:54 -0400 <19991022120954.B5228@intekom.com> Date: Fri, 22 Oct 1999 14:49:38 -0400 Message-ID: <21283.940618178@sss.pgh.pa.us> From: Tom Lane Grant Kaufmann writes: > My original choice was to use a trigger, but I don't want to introduce > C code when I don't have to. I don't believe that making external calls > should be necessary for a query that can be so simply expressed in SQL. Who said anything about C code? I was thinking of a pl/pgsql trigger, actually. The pl/pgsql section of the manual (programmer's guide under procedural languages) has an example of almost exactly this problem. If you do want to stick with rules then you'll need to make sure that the underlying insert is to a different table than the one the insert rule applies to --- in other words, create a view and have users insert into the view. regards, tom lane