Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 01BF4B5DCDB for ; Wed, 2 Nov 2011 07:22:20 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 72812-02 for ; Wed, 2 Nov 2011 10:22:13 +0000 (UTC) X-Greylist: delayed 00:05:27.05279 by SQLgrey-1.8.0-rc2 Received: from smtp209.alice.it (smtp209.alice.it [82.57.200.105]) by mail.postgresql.org (Postfix) with ESMTP id 35692B5DBF4 for ; Wed, 2 Nov 2011 07:22:13 -0300 (ADT) Received: from lan.webthatworks.it (95.236.222.14) by smtp209.alice.it (8.5.124.08) id 4E850A860395FD83 for pgsql-sql@postgresql.org; Wed, 2 Nov 2011 11:16:44 +0100 Received: from dawn.webthatworks.it (dawn.webthatworks.it [192.168.1.12]) by lan.webthatworks.it (Postfix) with ESMTP id 8AC593000F2 for ; Wed, 2 Nov 2011 11:16:43 +0100 (CET) Received: from dawn.webthatworks.it (localhost [127.0.0.1]) by dawn.webthatworks.it (Postfix) with ESMTP id 453C83DA98 for ; Wed, 2 Nov 2011 11:16:43 +0100 (CET) Date: Wed, 2 Nov 2011 11:16:42 +0100 From: Ivan Sergio Borgonovo To: pgsql-sql@postgresql.org Subject: \COPY in psql using \e Message-ID: <20111102111642.153ff4e5@dawn.webthatworks.it> Organization: http://www.webthatworks.it X-Mailer: Claws Mail 3.7.10 (GTK+ 2.24.7; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201111/2 X-Sequence-Number: 35975 I'm connecting to a DB with psql -h host DB once in psql I'd like to \e create temp table t1 ...; \copy t1 from 'filename' ... select * from t1; [ESC]:x what I get is: CREATE TABLE ERROR: syntax error at or near "select" LINE 3: select * from t1; ^ \copy: ERROR: syntax error at or near "select" LINE 3: select * from t1; ^ Now if I do: \e create temp table t1 ...; \copy t1 from 'filename' ... [ESC]:x select * from t1; everything works fine. I've a lot of script files that actually contain mixed \COPY and "plain" SQL statement eg. truncate table t1; \copy t1 from 'filename1' insert into d1...; truncate table t2; \copy t2 from 'filename2 insert into d1...; that I execute as: psql -h host DB < myscript.sql and everything is fine. Of course one solution could be to open a file in vi in a xterm and execute it from another xterm. Anything cleaner? thanks -- Ivan Sergio Borgonovo http://www.webthatworks.it