Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Te0V4-0004Ac-1R for pgsql-sql@arkaria.postgresql.org; Thu, 29 Nov 2012 09:33:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Te0V3-0004rG-IJ for pgsql-sql@arkaria.postgresql.org; Thu, 29 Nov 2012 09:33:41 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Te0V2-0004rB-VA for pgsql-sql@postgresql.org; Thu, 29 Nov 2012 09:33:41 +0000 Received: from sd-17937.dedibox.fr ([88.191.100.74]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Te0V1-0001ic-4e for pgsql-sql@postgresql.org; Thu, 29 Nov 2012 09:33:40 +0000 Received: from [192.168.1.16] (ATuileries-153-1-49-123.w83-202.abo.wanadoo.fr [83.202.80.123]) by sd-17937.dedibox.fr (Postfix) with ESMTPA id A947D3B914; Thu, 29 Nov 2012 10:44:05 +0100 (CET) Message-ID: <1354181617.2124.17.camel@localhost.localdomain> Subject: Re: \copy multiline From: Guillaume Lelarge To: Seb Cc: pgsql-sql@postgresql.org Date: Thu, 29 Nov 2012 10:33:37 +0100 In-Reply-To: <87r4ndnlfn.fsf@kolob.subpolar.dyndns.org> References: <87r4ndnlfn.fsf@kolob.subpolar.dyndns.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.4.4 (3.4.4-2.fc17) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) 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 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. -- Guillaume http://blog.guillaume.lelarge.info http://www.dalibo.com -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql