Re: Getting Primary Key Value After Insert

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Adam <adam(at)spatialsystems(dot)org>, Postgres general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: Getting Primary Key Value After Insert
Date: 2006-07-09 05:25:02
Message-ID: 20060709052502.68745.qmail@web31813.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I think I found the answer, you use the CURRVAL() function.
>
> Just to cover all the bases, consider this scenario in chronological order:
> 1. You insert data and the primary key is set to 20.
> 2. Someone else inserts data and the next key is set to 21.
> 3. If you call currval() will it return 20? I would think it does.

My understanding is that it will provided your are within a transaction. The following thread
showed a variation way to accomplish what you want.
http://archives.postgresql.org/pgsql-sql/2006-07/msg00095.php

Regards,

Richard Broersma Jr.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Glaesemann 2006-07-09 05:34:52 Re: Is OpenFTS dead?
Previous Message Adam 2006-07-09 05:00:31 Re: Getting Primary Key Value After Insert