On Thursday 08 April 2004 17:44, Shachar Shemesh wrote:
> Philippe Lang wrote:
> >
> >Is there a solution to that, except inserting records with PL-PGSQL, which
> > I already do in some cases, by the way...?
>
> I would love it if one of the resident Postgres gurus could verify this,
> but I think running "select currval('test_id_seq')" ought to do exactly
> what you want in this case. It should tell you the most recent id
> assigned by the sequence in your session.
>
> Can someone please verify that this command does not suffer races?
currval() and nextval() are guaranteed safe. What this does mean is that you
can end up with gaps in your sequence though.
--
Richard Huxton
Archonet Ltd