Re: Sequence - Use calculated start value?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Aragorn <aragorn(at)gondor(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Sequence - Use calculated start value?
Date: 2002-11-04 20:55:13
Message-ID: 20021104205513.GA12061@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Oct 30, 2002 at 18:02:00 +0000,
Aragorn <aragorn(at)gondor(dot)com> wrote:
> I need to use a calculated start value for some sequences. eg:
>
> CREATE SEQUENCE tblco_cntcoid_key start (SELECT (MAX(cntcoid) + 100)
> FROM tblco) increment 1 maxvalue 2147483647 minvalue 1 cache 1;

I think you need to do this in two steps. First create the sequence
and then use setval to set the starting value. I suspect that the
start value is not allowed to use select. The documention doesn't
make this absolutely clear, but I would be surprised if you could use
one here.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Patrick Bakker 2002-11-04 21:00:48 Re: [SQL] Database Design tool
Previous Message Doug McNaught 2002-11-04 20:38:39 Re: Can't import databases with pg_dump. Why?