X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2C83DD1E9FC for ; Thu, 1 Apr 2004 19:23:02 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 54630-09 for ; Thu, 1 Apr 2004 15:23:00 -0400 (AST) Received: from happy.onesystem.ca (happy.onesystem.ca [205.206.61.17]) by svr1.postgresql.org (Postfix) with ESMTP id 108F2D1E31E for ; Thu, 1 Apr 2004 15:22:56 -0400 (AST) Received: from elb_lx.onesystem.ca ([10.1.1.50]) by happy.onesystem.ca with asmtp (Exim 4.14) id 1B97m0-00053q-Gn; Thu, 01 Apr 2004 12:22:44 -0700 Subject: ECPG and COPY TO STDOUT From: Edmund Bacon To: pgsql-interfaces Content-Type: text/plain Message-Id: <1080847364.13873.14.camel@elb_lx.onesystem.ca> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Thu, 01 Apr 2004 12:22:44 -0700 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/1 X-Sequence-Number: 4822 If I use COPY TO STDOUT in an ECPG program, where does the output go? If I use COPY TO '/tmp/foo', I get the file created, with the data in it, but trying COPY TO STDOUT produces no output. What I'm trying to do is to dump a table's data, and have the resulting file owned by the application user rather than the dba user. I would rather to not have to create the file in /tmp, copy contents, rm /tmp file, if I don't have to. This is the program I'm using: #include EXEC SQL INCLUDE sqlca; EXEC SQL WHENEVER SQLERROR sqlprint; int main() { EXEC SQL BEGIN DECLARE SECTION; char *fname = "/tmp/foo"; EXEC SQL END DECLARE SECTION; EXEC SQL CONNECT TO test; /* produces expected file "/tmp/foo" */ EXEC SQL COPY foo TO :fname WITH DELIMITER ','; printf("copy to /tmp/foo : sqlca.sqlcode = %ld", sqlca.sqlcode); /* goes nowhere (?) */ EXEC SQL COPY foo TO STDOUT WITH DELIMITER ','; printf("copy to STDOUT : sqlca.sqlcode = %ld\n", sqlca.sqlcode); EXEC SQL DISCONNECT; return 0; } -- Edmund Bacon