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