Re: getting back autonumber just inserted

From: Vivek Khera <vivek(at)khera(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: getting back autonumber just inserted
Date: 2005-07-13 21:05:48
Message-ID: DC3A639A-7409-419C-9D1A-DABC091873F1@khera.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Jul 7, 2005, at 4:14 PM, Theodore Petrosky wrote:

>
> you have to use currval inside a transaction...
>
> begin;
> insert something that increments the counter;
> select currval('sequence_name');
> end;
>
> using currval inside a transaction guarantees that the
> value is correct for your insert statement and has not
> changed by another insert statement.
>

your understanding of currval() is completely incorrect. no
transaction is required.

In response to

Responses

  • int to date at 2005-07-25 08:54:42 from Daniel Drotos

Browse pgsql-sql by date

  From Date Subject
Next Message Luca Pireddu 2005-07-14 07:34:21 problem (bug?) with "in (subquery)"
Previous Message TJ O'Donnell 2005-07-13 17:24:01 Re: [SQL] dynamically loaded functions