Re: How I can read-back a serial value just inserted?

From: Russ Brown <pickscrape(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How I can read-back a serial value just inserted?
Date: 2007-01-18 16:01:56
Message-ID: 45AF99F4.3070608@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Robert Treat wrote:
> On Thursday 18 January 2007 00:57, Adam Rich wrote:
>> If it's a recent PG:
>>
>> select lastval()
>>
>> See this:
>>
>> http://www.postgresql.org/docs/8.2/interactive/functions-sequence.html
>>
>
> probably more important that you see this:
> http://people.planetpostgresql.org/xzilla/index.php?/archives/169-Is-lastval-evil.html
>
> :-)
>

lastval's main benefit is in aiding the port of MySQL apps (being a
drop-in replacement for LAST_INSERT_ID()). without lastval such ports
can be really difficult.

So it does have its place. :)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Devrim GUNDUZ 2007-01-18 16:06:06 Re: How I can read-back a serial value just inserted?
Previous Message Robert Treat 2007-01-18 15:43:06 Re: How I can read-back a serial value just inserted?