Sequence and nextval problem

From: Tk421 <vrobador(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Sequence and nextval problem
Date: 2008-11-24 19:12:12
Message-ID: 492AFC8C.302@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello everybody.

I've got an vb aplication that uses an Access database. I'm trying
to convert the database to postgres. The conversion was done ok, but
i've got a little problem that i don't know how to solve. Let's see if
anyone can help me.

The conversion from access database to postgres worked fine.
Everithing it's ok. But now, when i use my database i've found a problem
with sequences. In the conversion, the "autonumeric" fields from access
have been converted to sequences, everithing ok in a first view. The
problem comes because the autonumeric fields in access always return the
last value of the table +1, but postgres no. Postgres returns "lost" (i
don't know how to call them) values. An example.

This is an example of a table:

code | description
----- | ------------
1 | desc 1
2 | desc 2
6 | desc 6
7 | desc 7

In access if i execute "INSERT INTO table (description) VALUES
('desc 8'), the result row is 8 | desc 8
But in postgres the same query te result row is 3 | desc 8

My question is, can i do something to make ANY sequence to take the
last value from his associated table, and not a "lost" value?

Thank you very much

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Scott Marlowe 2008-11-24 19:20:25 Re: Sequence and nextval problem
Previous Message Tom Lane 2008-11-24 13:17:56 Re: Permission denied for create table