From: Leif Biberg Kristensen <leif@solumslekt.org>
To: pgsql-sql@postgresql.org
Subject: Re: Subselects not allowed?
Date: Sat, 11 Jun 2011 17:23:50 +0200
Message-ID: <201106111723.51057.leif@solumslekt.org> (raw)
In-Reply-To: <15640.1307805261@sss.pgh.pa.us>
References: <201106111701.54145.leif@solumslekt.org>
<1307804893.25444.5.camel@laptop>
<15640.1307805261@sss.pgh.pa.us>
On Saturday 11. June 2011 17.14.21 Tom Lane wrote:
> Guillaume Lelarge <guillaume@lelarge.info> writes:
> > On Sat, 2011-06-11 at 17:01 +0200, Leif Biberg Kristensen wrote:
> >> Can anybody tell me why this doesn't work?
> >> pgslekt=> CREATE SEQUENCE sources_source_id_seq START WITH (SELECT
> >> MAX(source_id) FROM sources);
> >> ERROR: syntax error at or near "("
> >
> > Because it's not supported. The START clause expects a value, not a
> > subquery.
>
> More generally, there are no "utility" statements in PG that accept
> non-constant expressions in their parameters. (A utility statement is
> anything other than SELECT, INSERT, UPDATE, DELETE.)
>
> There's been occasional speculation about changing that, but it would
> take a significant amount of work I think.
Thanks for the explanation, Tom.
Presumably this means that I can't automatically patch a live database to use
a sequence unless I build a special function for the update. With 9.x I could
use the new DO syntax, but that isn't yet deployed everywhere.
Unless there's a way around it?
regards, Leif
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: leif@solumslekt.org
Subject: Re: Subselects not allowed?
In-Reply-To: <201106111723.51057.leif@solumslekt.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox