Re: Getting OID after Insert

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Kevin HaleBoyes <kcboyes(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Getting OID after Insert
Date: 2001-10-24 13:39:22
Message-ID: 20011024233922.A3440@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Oct 23, 2001 at 02:38:04PM -0400, Kevin HaleBoyes wrote:
> Is this actually guaranteed to work?
> What happens if another call to append_test() is made such that
> the insert takes place in the first call, then the insert takes place
> in the second call before the select currval().

Yes, it's guarenteed to work. If you examine the documentation for
currval(), you will get the last value returned by nextval() *in this
session*. Whatever happens in other sessions is irrelevent.

I think this needs to be highlighted more in the documentation since many
people miss this very important point.
--
Martijn van Oosterhout <kleptog(at)svana(dot)org>
http://svana.org/kleptog/
> Magnetism, electricity and motion are like a three-for-two special offer:
> if you have two of them, the third one comes free.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tille, Andreas 2001-10-24 13:40:32 Re: Snapshot is not working
Previous Message Thomas Lockhart 2001-10-24 13:35:41 Re: Disable Transaction - plans ?