Re: inserting references

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: ktt <kestutis98(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: inserting references
Date: 2002-06-14 08:25:19
Message-ID: 20020614182519.A19721@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)svana(dot)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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Cornelia Boenigk 2002-06-14 10:50:49 Re: read this and puke
Previous Message ktt 2002-06-14 08:14:08 inserting references