Re: last inserted raw (identity) - Mailing list pgsql-general

From nolan@celery.tssi.com
Subject Re: last inserted raw (identity)
Date
Msg-id 20030802041830.8134.qmail@celery.tssi.com
Whole thread Raw
In response to Re: last inserted raw (identity)  (Ron Johnson <ron.l.johnson@cox.net>)
Responses Re: last inserted raw (identity)  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-general
> > See currval() and nextval().
>
> What if his PK isn't a sequence?

Moreover, currval() and nextval() won't guarantee that you always get the
most recently inserted sequence value, either, because each connection
can have a cache of sequence values to assign from.  While the backend
guarantees that each sequence value will be UNIQUE there is no guarantee
that MY currval() or nextval() is actually based on the last sequence value
that ANYONE used.

In short, I think the answer to the original question is that there is no
reliable way to find out what the last record inserted was.
--
Mike Nolan

pgsql-general by date:

Previous
From: "Eric Johnson"
Date:
Subject: Re: Using contrib/fulltext on multiple tables.
Next
From: Martijn van Oosterhout
Date:
Subject: Re: last inserted raw (identity)