Re: Implementing JDBC3 methods (Was: JDBC and fetching

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: Implementing JDBC3 methods (Was: JDBC and fetching
Дата
Msg-id 1032460936.26943.116.camel@inspiron.cramers
обсуждение исходный текст
Ответ на Re: Implementing JDBC3 methods (Was: JDBC and fetching  ("Ross J. Reedstrom" <reedstrm@rice.edu>)
Список pgsql-jdbc
Ross,

I realize that you can do this, but that is sort of going beyond what
most ppl will do. Also you can't insert a duplicate into a serial type.

But technically you are correct.

Dave
On Thu, 2002-09-19 at 10:57, Ross J. Reedstrom wrote:
> On Thu, Sep 19, 2002 at 05:25:01AM -0400, Dave Cramer wrote:
>
> > That's the only way, and will have to do. One thing to realize is that
> > once a sequence has been used, it can't be rolled back, so it is unique.
>
> Not really - you can set it to any number at all, or even reset it,
> so the first call to nextval() returns the inital value. I do this
> all the time when loading data into a schema, to set the sequences for
> serial columns so they don't cause errors, something like:
>
> select setval('mytable_id_seq',max(id)) from mytable
>
> Here's demonstrating resetting to 'virgin':
>
> test=# create sequence testit;
> CREATE
> test=# select nextval('testit');
>  nextval
> ---------
>        1
> (1 row)
>
> test=# select nextval('testit');
>  nextval
> ---------
>        2
> (1 row)
>
> test=# select currval('testit');
>  currval
> ---------
>        2
> (1 row)
>
> test=# select setval('testit',1,'f');
>  setval
> --------
>       1
> (1 row)
>
> test=# select nextval('testit');
>  nextval
> ---------
>        1
> (1 row)
>
> Ross
> --
> Ross Reedstrom, Ph.D.                                 reedstrm@rice.edu
> Executive Director                                  phone: 713-348-6166
> Gulf Coast Consortium for Bioinformatics              fax: 713-348-6182
> Rice University MS-39
> Houston, TX 77005
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
>




В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Ross J. Reedstrom"
Дата:
Сообщение: Re: Implementing JDBC3 methods (Was: JDBC and fetching
Следующее
От: "Sean Gates"
Дата:
Сообщение: Patch for 'updateNull' method null pointer exception