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 20:12:48 |
Message-ID: | 194f62550907261312u32372355lbc83a621552722a7@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-jdbc |
The problem is that I don't have control over the SQL generated, that
happens behind the scenes of the JDBCRowSet/SwingSet toolkt/api.
Fourtunatly it seems to work when I simply don't bind the textfield :)
However now I am facing other, jdbc-driver related problems, however
I'll ask on the jdk-list.
Thanks for all your help and patience, Clemens
2009/7/26 Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>:
> On Sun, Jul 26, 2009 at 11:20 AM, Clemens Eisserer<linuxhippy(at)gmail(dot)com> wrote:
>> 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
>
> Two methods:
>
> 1: Don't include the column in the insert:
>
> INSERT INTO custtype ("name",short) VALUES('test', 'ta');
>
> 2: Use the DEFAULT keyword:
>
> INSERT INTO custtype (key, "name",short) VALUES(DEFAULT, 'test', 'ta');
>
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2009-07-26 22:30:14 | Re: Is there a RECORD[] type in plpgsql? |
Previous Message | Clemens Eisserer | 2009-07-26 20:12:03 | Re: [GENERAL] Implicit sequence with start value? |
From | Date | Subject | |
---|---|---|---|
Next Message | Kris Jurka | 2009-07-27 06:26:26 | Re: Updateable ResultSet doesn't fetch sequence-generated values |
Previous Message | Clemens Eisserer | 2009-07-26 20:12:03 | Re: [GENERAL] Implicit sequence with start value? |