Re: PostgreSQL: Question about rules

From: "Jeremy Smith" <postgres(at)duckwizard(dot)com>
To: "Jeff Davis" <pgsql(at)j-davis(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: PostgreSQL: Question about rules
Date: 2006-11-16 23:25:05
Message-ID: 7353a39e0611161525o517c7a42i247ddd1b273cc649@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/16/06, Jeff Davis <pgsql(at)j-davis(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeremy Smith 2006-11-17 00:58:08 Re: PostgreSQL: Question about rules
Previous Message Jeff Davis 2006-11-16 23:17:13 Re: PostgreSQL: Question about rules