Re: [INTERFACES] locking on database updates

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "'Gary Stainburn'" <gary(dot)stainburn(at)ringways(dot)co(dot)uk>
Cc: "'Pgsql Interfaces'" <pgsql-interfaces(at)postgreSQL(dot)org>
Subject: Re: [INTERFACES] locking on database updates
Date: 1999-12-07 17:45:35
Message-ID: 23883.944588735@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

> The problem is that this does not actually give me the number that
> was just created. As there is no guarantee that the other fields in
> the table are unique (hence the serial field in the first place) I cannot
> simply do a select to retrieve it.

Easiest answer is to do

SELECT nextval('sequence_object');

and then INSERT the new row into your table using the value you just
obtained as an explicit value for the ID column, thus overriding the
default expression.

regards, tom lane

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tom Lane 1999-12-07 17:59:33 Re: [INTERFACES] locking on database updates
Previous Message Nicolas Huillard 1999-12-07 17:26:41 RE: [INTERFACES] locking on database updates