Re: [GENERAL] How to increment by hand a sequence number.

From: "Jose' Soares" <jose(at)sferacarta(dot)com>
To: Valerio Santinelli <tanis(at)mediacom(dot)it>
Cc: "pgsql-general(at)postgreSQL(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: [GENERAL] How to increment by hand a sequence number.
Date: 1999-01-19 14:19:01
Message-ID: 36A49455.7A28742@sferacarta.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Valerio Santinelli wrote:
>
> I've exported a table from an existing MSAccess database to my
> PostgreSQL db.
> I use a serial ID on the table and now I'm getting errors when I add a
> new entry in the table if i don't specify the ID by hand (which should
> be placed automatically by the db since it's a serial).
>
> The exact error is this one:
>
> Cannot insert a duplicate key into a unique index.
>
> I think I should set the "last_value" field in the sequence to my real
> last value aon the ID field of the table, but Idon't know how to do it.
> Is there anybody who can help me ?
>
> Thanks
>
> Valerio Santinelli
> tanis(at)mediacom(dot)it

You may drop the sequence and then re-create it by specifying the start
as in:

DROP SEQUENCE contatore;
CREATE SEQUENCE contatore START 101;

Or if you desire you can increment the counter like this:

SELECT NEXTVAL ('contatore');

Buon divertimento!
-Jose'-

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Valerio Santinelli 1999-01-19 14:58:16 Another one! :) How to convert char(1) to boolean without re-exporting tables.
Previous Message Randy Dees 1999-01-19 14:07:33 Access database from PostgreSQL?