From: | "Alain Roger" <raf(dot)news(at)gmail(dot)com> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: sequence |
Date: | 2007-12-09 15:56:56 |
Message-ID: | 75645bbb0712090756h3cf26f6cu7c814b0348fc2a3d@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Tom,
but when i let pgsql setup everything (i mean when i create table -> pgsql
creates sequence)
), i have called = no, before using any select nextval()...
and in this case, it works great.
but once called = yes, select nextval(sequence_name); always gives me
current value +1 :-(
A.
On Dec 9, 2007 4:51 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Alain Roger" <raf(dot)news(at)gmail(dot)com> writes:
> > to perform an autoincrement in my SQL queries...specially while i use
> insert
> > into i do the following thing :
>
> > INSERT INTO mytable VALUES
> > (
> > select nextval('users_user_id_seq'),
> > ...
> > );
>
> > however this get the currentvalue + 1, or during creating the sequence i
> > must say that start = 0.
>
> Really? Works fine for me:
>
> regression=# create sequence foo start with 10;
> CREATE SEQUENCE
> regression=# select nextval('foo');
> nextval
> ---------
> 10
> (1 row)
>
> regression=# select nextval('foo');
> nextval
> ---------
> 11
> (1 row)
>
> If you're initializing the sequence some other way, such as with
> setval(), maybe you need to make use of the is_called option to setval().
>
> regards, tom lane
>
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.2.4 / MS SQL server 2005
Apache 2.2.4
PHP 5.2.4
C# 2005-2008
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2007-12-09 16:04:38 | Re: sequence |
Previous Message | Tom Lane | 2007-12-09 15:51:32 | Re: sequence |