Re: problem with serial

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Yvon Thoraval <yvon(dot)thoraval(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: problem with serial
Date: 2012-04-19 14:42:16
Message-ID: 4F902448.2000300@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/19/2012 07:19 AM, Yvon Thoraval wrote:
> i do have a serial named 'rowid' it is of "SERIAL PRIMARY KEY" in a
> table 'items'.
>
> if i delete some of the rows i can't anymore insert afterwards.
>
> even if i rearrange de sequence by :
>
> "SELECT MAX(rowid) FROM items;";
> "SELECT last_value FROM items_rowid_seq;";
> then if last_value is lower than MAX(rowid) i set it to MAX(rowid) :
> "SELECT setval('items_rowid_seq', max(rowid)) FROM items;";
>
> and even after that i get an error when inserting by :
> "INSERT ... RETURNING rowid;"
>
> here I'm not only unable to read back the rowid but also inserion failed.

What does the error say?

>
> why ?
> --
> Yvon
>
>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2012-04-19 14:55:04 Re: problem with serial
Previous Message Yvon Thoraval 2012-04-19 14:19:34 problem with serial