Re: serial type vs. sequences

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Suchandra Thapa <s-thapa-11(at)alumni(dot)uchicago(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: serial type vs. sequences
Date: 2003-11-12 21:17:37
Message-ID: 20031112211737.GB2077@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Nov 12, 2003 at 14:59:33 -0600,
Suchandra Thapa <s-thapa-11(at)alumni(dot)uchicago(dot)edu> wrote:
> I was wondering if there was a reliable method to get the last id
> inserted into a serial column in a table. I believe previous
> recommendations given were to use a sequence, have your app get the
> nextval for the sequence and then use that in the insert. I was
> wondering if things had changed or if that is still the recommended
> method.

It is probably a little better to use currval rather than remembering
what nextval returned in your application.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christopher Murtagh 2003-11-12 21:24:53 Re: pl/perl function life and variable scope -
Previous Message scott.marlowe 2003-11-12 21:17:31 Re: SQL-question: returning the id of an insert querry