Re: Getting last inserted SERIAL

From: Dennis Björklund <db(at)zigo(dot)dhs(dot)org>
To: mgarriss <mgarriss(at)earthlink(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Getting last inserted SERIAL
Date: 2003-09-01 04:02:09
Message-ID: Pine.LNX.4.44.0309010600320.4053-100000@zigo.dhs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, 31 Aug 2003, mgarriss wrote:

> First thought is "SELECT CURRVAL('test_id_seq');" but this assumes that
> there is only one connection inserting into this table, bad assumption.

That is what you should use, and it works for concurrent sessions. It's
all described in the manual:

http://www.postgresql.org/docs/7.3/static/functions-sequence.html

--
/Dennis

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2003-09-01 04:04:13 Re: Getting last inserted SERIAL
Previous Message Bruce Momjian 2003-09-01 03:57:10 Re: About GPL and proprietary software