Re: Maybe a bug found with nextval() function

Поиск
Список
Период
Сортировка
От Joe Sunday
Тема Re: Maybe a bug found with nextval() function
Дата
Msg-id 20040220215107.GA25768@csh.rit.edu
обсуждение исходный текст
Ответ на Maybe a bug found with nextval() function  (Alexander Troppmann <talex@cocktaildreams.de>)
Список 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 по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: i have one doubt
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Hang in PQgetResult