Re: Maybe a bug found with nextval() function - Mailing list pgsql-bugs

From Joe Sunday
Subject Re: Maybe a bug found with nextval() function
Date
Msg-id 20040220215107.GA25768@csh.rit.edu
Whole thread Raw
In response to Maybe a bug found with nextval() function  (Alexander Troppmann <talex@cocktaildreams.de>)
List 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@csh.rit.edu>  http://www.csh.rit.edu/~sunday/
Computer Science House, Rochester Inst. Of Technology

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: i have one doubt
Next
From: Tom Lane
Date:
Subject: Re: Hang in PQgetResult