Re: last inserted raw (identity)

From: nolan(at)celery(dot)tssi(dot)com
To: ron(dot)l(dot)johnson(at)cox(dot)net (Ron Johnson)
Cc: pgsql-general(at)postgresql(dot)org (postgresql)
Subject: Re: last inserted raw (identity)
Date: 2003-08-02 04:18:30
Message-ID: 20030802041830.8134.qmail@celery.tssi.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gavin M. Roy 2003-08-02 04:18:33 Re: plPHP -- sort of an announcement.. but not commercial
Previous Message Martijn van Oosterhout 2003-08-02 04:09:16 Re: last inserted raw (identity)