Re: Implicit sequence with start value?

From: Clemens Eisserer <linuxhippy(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Implicit sequence with start value?
Date: 2009-07-26 17:20:41
Message-ID: 194f62550907261020p569d3440s17f4edbfd88b0ba4@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc

Hi Tom,

> regression=# alter sequence foo_bar_seq start with 1000;
> ALTER SEQUENCE
Completly forgot about that possibility, thanks a lot :)

What still puzzles me is how to get the sequence value applied.
MySQL's auto_increment simply ignores whatever value is supplied to
it, however postgres seems to insert the value instead of the next
sequence value, if one is supplied:

> CREATE TABLE custtype (key SERIAL PRIMARY KEY NOT NULL, name VARCHAR(127) NOT NULL, short VARCHAR(4));
> ALTER SEQUENCE custtype_key_seq START WITH 10000;");
> INSERT INTO custtype VALUES(0, 'test', 'ta');
>
> key | name | short
> -----+----------------+-------
> 0 | test | ta

Of course, under normal circumstances it would be no problem to insert
a nextval() however I am using an updateable JDBC ResultSet.
Any idea how I can force the sequence's nextval() value into the key
column using ResultSets?

Thank you in advance, Clemens

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2009-07-26 17:28:46 Re: Implicit sequence with start value?
Previous Message Tom Lane 2009-07-26 16:18:37 Re: Implicit sequence with start value?

Browse pgsql-jdbc by date

  From Date Subject
Next Message Raymond O'Donnell 2009-07-26 17:28:46 Re: Implicit sequence with start value?
Previous Message Tom Lane 2009-07-26 16:18:37 Re: Implicit sequence with start value?