X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5289DD1D8DA for ; Tue, 17 Feb 2004 16:29:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 29855-07 for ; Tue, 17 Feb 2004 12:29:47 -0400 (AST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 560D7D1D8BF for ; Tue, 17 Feb 2004 12:29:47 -0400 (AST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 7439D3561E; Tue, 17 Feb 2004 08:29:06 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 7317F3561C; Tue, 17 Feb 2004 08:29:06 -0800 (PST) Date: Tue, 17 Feb 2004 08:29:06 -0800 (PST) From: Stephan Szabo To: Karl Denninger Cc: pgsql-sql@postgresql.org Subject: Re: Ok, what am I doing wrong here? In-Reply-To: <20040217100250.A65968@Denninger.Net> Message-ID: <20040217082231.C41055@megazone.bigpanda.com> References: <20040217100250.A65968@Denninger.Net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/212 X-Sequence-Number: 16902 sszabo@bigpanda.com On Tue, 17 Feb 2004, Karl Denninger wrote: > I want to insert values from one table into another, and add some "default" > values (that are not defaults on the table different reasons - that is, this > is maintenance function and in normal operation there would be "real" values > there - and null is valid) > > So, I want to do, for example, the following: > > insert into table (id, time, type) values (select id, now(), '1' from secondtable); > > Postgres's command line pukes on this, complaining that "select" is invalid > inside the values part of the definition. > > SQL's language specification says otherwise, as does "\h insert" from the > command line. I think what you want is insert into table (id, time, type) select id, now(), '1' from secondtable; The choices allowed right now are default values, something that is basically a row constructor with values [*] or a query. [*] - The full spec allows a list of row constructors but we don't currently.