Re: inserting references

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: ktt <kestutis98(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: inserting references
Date: 2002-06-14 13:43:27
Message-ID: 5851.1024062207@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Martijn van Oosterhout <kleptog(at)svana(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-06-14 14:01:05 Re: read this and puke
Previous Message Cornelia Boenigk 2002-06-14 13:04:55 Fw: read this and puke