Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Te692-00011L-E7 for pgsql-sql@arkaria.postgresql.org; Thu, 29 Nov 2012 15:35:20 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Te691-0006ap-Os for pgsql-sql@arkaria.postgresql.org; Thu, 29 Nov 2012 15:35:19 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Te691-0006ak-69 for pgsql-sql@postgresql.org; Thu, 29 Nov 2012 15:35:19 +0000 Received: from mail-ie0-f174.google.com ([209.85.223.174]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Te68z-0000GI-1N for pgsql-sql@postgresql.org; Thu, 29 Nov 2012 15:35:18 +0000 Received: by mail-ie0-f174.google.com with SMTP id k11so12226520iea.19 for ; Thu, 29 Nov 2012 07:35:15 -0800 (PST) Received: by 10.50.85.130 with SMTP id h2mr22900586igz.26.1354203315689; Thu, 29 Nov 2012 07:35:15 -0800 (PST) Received: from smtp.gmail.com (S0106c8d719636840.wp.shawcable.net. [24.77.164.163]) by mx.google.com with ESMTPS id xn10sm7434792igb.4.2012.11.29.07.35.14 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 29 Nov 2012 07:35:14 -0800 (PST) From: Sebastian P. Luque To: pgsql-sql@postgresql.org Subject: Re: \copy multiline References: <87r4ndnlfn.fsf@kolob.subpolar.dyndns.org> <1354181617.2124.17.camel@localhost.localdomain> Mail-Followup-To: pgsql-sql@postgresql.org Date: Thu, 29 Nov 2012 09:35:13 -0600 In-Reply-To: <1354181617.2124.17.camel@localhost.localdomain> (Guillaume Lelarge's message of "Thu, 29 Nov 2012 10:33:37 +0100") Message-ID: <877gp4o21a.fsf@kolob.subpolar.dyndns.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Organization: University of Manitoba MIME-Version: 1.0 Content-Type: text/plain X-Pg-Spam-Score: -1.7 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On Thu, 29 Nov 2012 10:33:37 +0100, Guillaume Lelarge wrote: > On Wed, 2012-11-28 at 21:21 -0600, Seb wrote: >> Hi, >> I use \copy to output tables into CSV files: >> \copy (SELECT ...) TO 'a.csv' CSV >> but for long and complex SELECT statements, it is cumbersome and >> confusing to write everything in a single line, and multiline >> statements don't seem to be accepted. Is there an alternative, or am >> I missing an continuation-character/option/variable that would allow >> multiline statements in this case? > A simple way to workaround this issue is to create a view with your > query and use the view in the \copy meta-command of psql. Of course, > it means you need to have the permission to create views in the > database. Thanks. Someone also suggested creating a temporary view, which helps keep the schema sane and clean. Cheers, -- Seb -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql