Re: Maybe a bug found with nextval() function

From: Joe Sunday <sunday(at)csh(dot)rit(dot)edu>
To: Alexander Troppmann <talex(at)cocktaildreams(dot)de>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Maybe a bug found with nextval() function
Date: 2004-02-20 21:51:08
Message-ID: 20040220215107.GA25768@csh.rit.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Feb 19, 2004 at 07:16:42PM +0100, Alexander Troppmann wrote:

> SELECT SETVAL('recipe_id_seq', max(id)) FROM recipe;
>
> returns the following output:
>
> setval
> --------
> 455
> (1 row)

Ok.

> Now I tried to fetch the next free primary key id for my "recipe" table:
>
> SELECT NEXTVAL('recipe_id_seq') FROM receipt;

You're going to get a value for every row in receipt, which is what you're
seeing.

What you want is
SELECT NEXTVAL( 'recipe_id_seq');

--Joe

--
Joe Sunday <sunday(at)csh(dot)rit(dot)edu> http://www.csh.rit.edu/~sunday/
Computer Science House, Rochester Inst. Of Technology

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Wade Klaver 2004-02-20 22:12:29 Re: date_part returns different results with same interval.
Previous Message Tom Lane 2004-02-20 21:16:05 Re: Hang in PQgetResult