Re: inserting references - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: inserting references
Date
Msg-id 20020614182519.A19721@svana.org
Whole thread Raw
In response to inserting references  (ktt <kestutis98@yahoo.com>)
Responses Re: inserting references  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
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.
>
> What are better methods for doing
> this(exept LAST_INSERT_ID())?
> Would be nice to use the most compact form.

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

> sample tables scheme
>
> -----------   ----------   ----------   ----------
>
> fruits        bananas      oranges      kivi
>
> -----------   ----------   ----------   ----------
>
> fruits_id     bananas_id   oranges_id   kivi_id
>
> bananas_id    date_bn      date_or      date_kv
>
> oranges_id    ----------   ----------   ----------
>
> kivi_id
> country
>
> -----------
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> There are 10 kinds of people in the world, those that can do binary
> arithmetic and those that can't.

pgsql-general by date:

Previous
From: ktt
Date:
Subject: inserting references
Next
From: Oleg Bartunov
Date:
Subject: Re: jobs.postgresql.org - Who's interested?