Re: Getting OID after Insert

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Kevin HaleBoyes <kcboyes(at)yahoo(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Getting OID after Insert
Date: 2001-10-24 17:35:31
Message-ID: 200110241735.f9OHZVG01176@candle.pha.pa.us
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.

I have highlighted it more in the FAQ. Yes, many people miss that.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John Hasler 2001-10-24 17:41:11 Re: GUID in postgres
Previous Message Alex Pilosov 2001-10-24 17:25:11 Re: plperl and table/record access