Re: inserting references - Mailing list pgsql-general

From Tom Lane
Subject Re: inserting references
Date
Msg-id 5851.1024062207@sss.pgh.pa.us
Whole thread Raw
In response to Re: inserting references  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
Martijn van Oosterhout <kleptog@svana.org> writes:
> On Fri, Jun 14, 2002 at 01:14:08AM -0700, ktt wrote:
>> I have a table, which references
>> values in other 3 tables.
>>
>> I would like to insert values in
>> bananas, oranges and kivi tables
>> and insert their bananas_id,oranges_id,kivi_id,
>> country
>> in fruits table.

> If you're using sequences, just use currval() in the insert statement for
> fruits.

If this is always supposed to happen, why have the client issue insert
commands against fruits at all?  Set up ON INSERT triggers on the detail
tables that issue inserts into the summary table.  They can get all the
info they need from the "new" record for the detail table.

            regards, tom lane

pgsql-general by date:

Previous
From: "Cornelia Boenigk"
Date:
Subject: Re: read this and puke
Next
From: Tom Lane
Date:
Subject: Re: read this and puke