Re: PostgreSQL: Question about rules - Mailing list pgsql-general

From Jeremy Smith
Subject Re: PostgreSQL: Question about rules
Date
Msg-id 7353a39e0611161525o517c7a42i247ddd1b273cc649@mail.gmail.com
Whole thread Raw
In response to Re: PostgreSQL: Question about rules  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: PostgreSQL: Question about rules
List pgsql-general
On 11/16/06, Jeff Davis <pgsql@j-davis.com> wrote:

create rule "child_with_parent_explicit_insert" as
        on insert to child_with_parent_explicit do instead (
                insert into parent(id, foo) values(COALESCE
(new.id ,NEXTVAL('parent_id_seq')), new.foo);
                insert into child(id, bar) values(COALESCE
(new.id,CURRVAL('parent_id_seq')), new.bar);
        );


I'm not sure if this is what you're looking for, but does this help?

Regards,
        Jeff Davis


COALESCE is certainly something I had never heard of.  I think that will solve my problem quite effectively.  Thanks for your help!

Jeremy

pgsql-general by date:

Previous
From: Jeff Davis
Date:
Subject: Re: PostgreSQL: Question about rules
Next
From: "Jeremy Smith"
Date:
Subject: Re: PostgreSQL: Question about rules