Re: DO INSTEAD and conditional rules

From: David Wheeler <david(at)kineticode(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Rob Butler <crodster2k(at)yahoo(dot)com>, Neil Conway <neilc(at)samurai(dot)com>, Jan Wieck <JanWieck(at)yahoo(dot)com>
Subject: Re: DO INSTEAD and conditional rules
Date: 2005-04-26 22:06:31
Message-ID: 79e6a42116d6cd9a74bb021041d3953a@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Apr 26, 2005, at 2:58 PM, Tom Lane wrote:

> ... which indeed can be a feature, not a bug, depending on what you're
> doing ...

Absolutely. An INSERT rule I have looks like this:

CREATE RULE insert_one AS
ON INSERT TO one WHERE NEW.id IS NULL
DO INSTEAD (
INSERT INTO _simple (id, guid, state, name, description)
VALUES (NEXTVAL('seq_kinetic'), NEW.guid, NEW.state, NEW.name,
NEW.description);

INSERT INTO simple_one (id, bool)
VALUES (CURRVAL('seq_kinetic'), NEW.bool);
);

The call to NEXTVAL() in the first statement sets up a value I use in
the second via CURRLVA().

Cheers,

David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Held 2005-04-26 22:43:14 Re: [HACKERS] Bad n_distinct estimation; hacks suggested?
Previous Message Gurmeet Manku 2005-04-26 22:00:48 Re: [HACKERS] Bad n_distinct estimation; hacks suggested?