Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 5181FB5DBCA for ; Sat, 11 Jun 2011 12:14:33 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 16886-04 for ; Sat, 11 Jun 2011 15:14:26 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id EC64CB5DBC1 for ; Sat, 11 Jun 2011 12:14:25 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p5BFELIe015641; Sat, 11 Jun 2011 11:14:22 -0400 (EDT) To: Guillaume Lelarge cc: Leif Biberg Kristensen , pgsql-sql@postgresql.org Subject: Re: Subselects not allowed? In-reply-to: <1307804893.25444.5.camel@laptop> References: <201106111701.54145.leif@solumslekt.org> <1307804893.25444.5.camel@laptop> Comments: In-reply-to Guillaume Lelarge message dated "Sat, 11 Jun 2011 17:08:12 +0200" Date: Sat, 11 Jun 2011 11:14:21 -0400 Message-ID: <15640.1307805261@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201106/36 X-Sequence-Number: 35502 Guillaume Lelarge 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. regards, tom lane