From: | Leif Biberg Kristensen <leif(at)solumslekt(dot)org> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Subselects not allowed? |
Date: | 2011-06-11 15:23:50 |
Message-ID: | 201106111723.51057.leif@solumslekt.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Saturday 11. June 2011 17.14.21 Tom Lane wrote:
> Guillaume Lelarge <guillaume(at)lelarge(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Leif Biberg Kristensen | 2011-06-11 15:39:04 | Re: Subselects not allowed? |
Previous Message | Andreas Kretschmer | 2011-06-11 15:23:40 | Re: Subselects not allowed? |