Received: from candle.pha.pa.us (candle.navpoint.com [162.33.245.46]) by postgresql.org (8.11.3/8.11.4) with ESMTP id fATMHim34526; Thu, 29 Nov 2001 17:17:44 -0500 (EST) (envelope-from pgman@candle.pha.pa.us) Received: (from pgman@localhost) by candle.pha.pa.us (8.11.6/8.10.1) id fATMHdZ12712; Thu, 29 Nov 2001 17:17:39 -0500 (EST) From: Bruce Momjian Message-Id: <200111292217.fATMHdZ12712@candle.pha.pa.us> Subject: Re: CREATE RULE ON UPDATE/DELETE In-Reply-To: <20011021222604.6211.qmail@ns.krot.org> "from Aasmund Midttun Godal at Oct 21, 2001 10:26:03 pm" To: Aasmund Midttun Godal Date: Thu, 29 Nov 2001 17:17:39 -0500 (EST) CC: tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org, joel@joelburton.com, pgsql-sql@postgresql.org X-Mailer: ELM [version 2.4ME+ PL90 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-Archive-Number: 200111/422 X-Sequence-Number: 5804 I have added the following text to the CREATE TRIGGER manual page to address this issue. It often confuses people so it is good to point out: SELECT does not modify any rows so you can not create SELECT triggers. --------------------------------------------------------------------------- > Yes, I agree perfectly... I never thought of that! I would really like it if some more info was added to the docs regarding info on rules and triggers. The section on update rules is quite good, but some more would never hurt. One point in the trigger vs rules section which at least to me is very important is the simple fact that you cannot have a trigger on a select... Ok I understand why - but it took some time... > > Thank you for answering my questions! > > regards, > > Aasmund. > On Sun, 21 Oct 2001 12:47:41 -0400, Tom Lane wrote: > > Joel Burton writes: > > > > > > Surely you'd need something like > > > > CREATE RULE dbl_update AS ON UPDATE TO dbl DO INSTEAD UPDATE raw SET > > id = NEW.id / 2, name = NEW.name WHERE OLD.id = id * 2; > > > > (untested...) > > > > regards, tom lane > > Aasmund Midttun Godal > > aasmund@godal.com - http://www.godal.com/ > +47 40 45 20 46 > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026