Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 1480A9FB2C4 for ; Sun, 11 Feb 2007 19:55:22 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 09369-07 for ; Sun, 11 Feb 2007 19:55:04 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from vms046pub.verizon.net (vms046pub.verizon.net [206.46.252.46]) by postgresql.org (Postfix) with ESMTP id A29139FB277 for ; Sun, 11 Feb 2007 19:55:08 -0400 (AST) Received: from [192.168.7.5] ([71.101.14.31]) by vms046.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0JDB00BMBP3QNV8B@vms046.mailsrvcs.net> for pgsql-sql@postgresql.org; Sun, 11 Feb 2007 17:55:03 -0600 (CST) Date: Sun, 11 Feb 2007 18:55:35 -0500 From: Joe Subject: Re: COPY FROM query. In-reply-to: <45CFA478.5020505@autoledgers.com.au> To: Paul Lambert Cc: pgsql-sql@postgresql.org Message-id: <1171238135.783.2.camel@pampa> Organization: Freedom Circle, LLC MIME-version: 1.0 X-Mailer: Evolution 2.8.3 FreeBSD GNOME Team Port Content-type: text/plain Content-transfer-encoding: 7bit References: <45CFA478.5020505@autoledgers.com.au> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200702/132 X-Sequence-Number: 27466 Hi Paul, On Mon, 2007-02-12 at 08:19 +0900, Paul Lambert wrote: > I'm attempting to copy from a table into a file using a select query > inside the copy. > > The following is my command: > > COPY (SELECT DISTINCT ON (dealer_id,appraisal_id) * FROM > appraisals_temp) TO 'c:\autodrs_appraisal_new.txt' WITH DELIMITER AS '^' > CSV HEADER; > > I get the following returned: > > WARNING: nonstandard use of escape in a string literal > LINE 1: ...ealer_id,appraisal_id) * FROM appraisals_temp) TO 'C:\autodr... > ^ > HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. > > ERROR: relative path not allowed for COPY to file > SQL state: 42602 > > > (The caret character is pointing to the M in FROM) I believe that on Windows you need to use double backslashes, i.e., 'c:\ \autodrs_appraisal_new.txt', although the regular slash may also work, i.e., 'c:/autodrs_appraisal_new.txt'. Joe