Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T8zEJ-0003lz-JP for pgsql-general@postgresql.org; Tue, 04 Sep 2012 19:56:11 +0000 Received: from wsip-72-214-29-243.sd.sd.cox.net ([72.214.29.243] helo=joeconway.com) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1T8zEI-0000oK-OP for pgsql-general@postgresql.org; Tue, 04 Sep 2012 19:56:11 +0000 Received: from www.joeconway.com (account jconway [192.168.4.40] verified) by joeconway.com (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 12269089; Tue, 04 Sep 2012 12:56:09 -0700 Message-ID: <50465CD9.3050809@joeconway.com> Date: Tue, 04 Sep 2012 12:56:09 -0700 From: Joe Conway User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.8.0.12) Gecko/20071019 Fedora/1.5.0.12-3.fc6 pango-text Thunderbird/1.5.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: Aram Fingal CC: Postgres-General General Subject: Re: crosstab References: <1346773199616-5722632.post@n5.nabble.com> <1346784707.8977.6.camel@asus-1001PX.home> <73FF0C6A-965B-4456-BA90-2B8FD1CBC118@multifactorial.com> <504655DD.4030701@joeconway.com> <09AE4623-B1E5-4F8D-AC55-EF5906A6411C@multifactorial.com> In-Reply-To: <09AE4623-B1E5-4F8D-AC55-EF5906A6411C@multifactorial.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.9 (/) X-Archive-Number: 201209/98 X-Sequence-Number: 190114 On 09/04/2012 12:48 PM, Aram Fingal wrote: > So, are you saying that if I do something like this: > > copy(crosstab(source_sql, category_sql)) to '/output.csv' with csv; > > Then I don't have to list what the columns are going to be? In other > words, I can skip the "AS (...)" clause which is shown in the > examples in the tablefunc documentation? No, sorry, but that is not what I'm saying :-( Wen you run copy ("some query") to ... it still requires postgres to execute "some query" and the standard grammar rules will be applied. Postgres must be able to resolve data types for the columns in the result, and therefore it needs you to provide a column definition either at function creation time (via OUT params or by explicit composite return type) or at execution time via AS(...) clause. Joe -- Joe Conway credativ LLC: http://www.credativ.us Linux, PostgreSQL, and general Open Source Training, Service, Consulting, & 24x7 Support